Пожалуйста, помогите [RecyclerView]:
[E / RecyclerView: адаптер не подключен; пропускающий макет]
Мой код:
class UsersAdapter (private val usersList:List<User>) : RecyclerView.Adapter <CustomViewHolder>() {
override fun getItemCount(): Int {
return usersList.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomViewHolder {
val layoutInflater = LayoutInflater.from(parent?.context)
val cellForRow = layoutInflater.inflate(R.layout.users_list, parent, false)
return CustomViewHolder(cellForRow)
}
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) {
val user = usersList[position]
Log.d("Yasser", "onResponse: ${user.name}")
holder.view.UsersPersonName.text = user.name
holder.view.UsersShortPersonName.text = user.name.substring(0).capitalize()
holder.view.UsersPersonEmail.text = user.email
}
}
class CustomViewHolder(val view: View): RecyclerView.ViewHolder(view) {
}
UserActivity:
class UsersActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_users)
RetrofitClient.instance.getUsers().enqueue(object: Callback<List<User>>{
override fun onResponse(call: Call<List<User>>, response: Response<List<User>>) {
showData(response.body()!!)
}
override fun onFailure(call: Call<List<User>>, t: Throwable) {
d("Fail","onFailure")
}
})
}
private fun showData(usersList: List<User>) {
listUsersRecycle.apply {
layoutManager = LinearLayoutManager(this@UsersActivity)
adapter = UsersAdapter(usersList)
}
}
Я много пробовал, но это дает мне то же самое, как я могу решить эту ошибку [Kotlin]?