目录
1.配置gradle
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
2.Retrofit请求网络
(1)定义返回数据实体类
class User(var name:String,var age:Int)
(2)定义请求接口
interface UserService {
@GET("name = tom")
fun getUser():Call<User>
}
(3)创建Retrofit请求网络
private fun retrofitRequest