At the moment of creating an adapter for a recyclerView I could not make it recognize the layout that happened to it and the elements that are in it.
class adapter_wpHome(val mItems: List<content_wallp>, val context : Context) : RecyclerView.Adapter<adapter_wpHome.viewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): viewHolder {
return viewHolder(LayoutInflater.from(parent.context).inflate(R.layout.cv_list_wall, parent, false))
}
override fun getItemCount(): Int = mItems.size
override fun onBindViewHolder(holder: viewHolder, position: Int) {
holder.bindItems(mItems[position])
}
class viewHolder( itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bindItems ( item : content_wallp){
Glide.with(itemView.context).load(item.path).into(itemView.img_wallp) // aqui no encuentra el elemento img_wallp en el layout
}
}
}
It is worth noting that I have 3 more applications where I have done the adapter in the same way and everything works perfectly, I do not know why it has failed, I have already reviewed all the other adapters (my other apps) and they are the same! I do not know what's wrong, the app was all in java and I'm passing it to Kotlin, in this class I used the android studio option that says "From java to Kotlin", the adapter I'm creating in the same class that I'm going to use, the data class equally and it is not an activity, it is a fragment, thanks for the collaboration.