我有这个功能
val client = NetworkService()
val call = client.getService().getAllPost()
call.enqueue(object : Callback<ArrayList<Post>>{
override fun onFailure(call: Call<ArrayList<Post>>, t: Throwable) {
Toast.makeText(this@MainActivity, "Get post failed", Toast.LENGTH_LONG).show()
}
override fun onResponse(
call: Call<ArrayList<Post>>,
response: Response<ArrayList<Post>>) {
response.body()?.let{
post ->
adapter?.updateData(post)
}?: kotlin.run {
Toast.makeText(this@MainActivity, "Get post failed", Toast.LENGTH_LONG).show()
}
}
})
}
Run Code Online (Sandbox Code Playgroud)
*并有错误*
Type mismatch: inferred type is <no name provided> but Callback<Post!>! was expected
在call.enqueue(object : Callback<ArrayList<Post>>
回调 ArrayList 中不想使用对象,不知道为什么
请帮忙这个
| 归档时间: |
|
| 查看次数: |
8212 次 |
| 最近记录: |