Good I have two layouts created odd and even in the form of a card and I want them to be sent according to odd or even the position to the main layout that would be the recyclerView and I do not know how to work the adapter so that I can only send the data to 1 layout.
class AdaptadorCustumon(var contexto: Context, items: ArrayList<BookItem>): RecyclerView.Adapter<AdaptadorCustumon.ViewHolder>() {
var items:ArrayList<BookItem>? = null
var viewHolder : ViewHolder? = null
init {
this.items = items
}
override fun onCreateViewHolder(parent: ViewGroup, viewType : Int): AdaptadorCustumon.ViewHolder {
val vista = LayoutInflater.from(contexto).inflate(R.layout.card_impar, parent,false)
viewHolder = ViewHolder(vista)
return viewHolder!!
}
override fun getItemCount(): Int {
return this.items?.count()!!
}
override fun onBindViewHolder(holder :ViewHolder, position: Int) {
val item = items?.get(position)
holder.autor?.text = item?.autor
holder.titulo?.text = item?.titulo
}
class ViewHolder(vista : View) : RecyclerView.ViewHolder(vista){
var vista = vista
var autor : TextView? = null
var titulo : TextView? = null
init {
titulo = vista.findViewById(R.id.tvTitulo1)
autor = vista.findViewById(R.id.tvAutor1)
}
}
}