Guruh: 314-17 Bajardi: Ne’matjonov A


var image:ImageView var


Download 1.68 Mb.
bet20/22
Sana08.01.2022
Hajmi1.68 Mb.
#247739
1   ...   14   15   16   17   18   19   20   21   22
Bog'liq
Ne'matjonov Abduvohid

var image:ImageView

var text: TextView

init {


image = itemView.category_icon

text=itemView.category_title

}

fun setData(data: CategoryData) {

image.setImageResource(data.image)

text.setText(data.title)

}

}



}

class HomeAdapter(var context: Context): RecyclerView.Adapter() {


var data: ArrayList? = null


var onItemClickListener: OnItemClickListener? = null





fun setItemClickListener(onItemClickListener: OnItemClickListener) {


this.onItemClickListener=onItemClickListener

}

fun setList(list: ArrayList) {




if (data == null) {

data = list


notifyItemRangeInserted(0, list.size)


} else {


data?.addAll(list)


notifyItemRangeInserted(data!!.size-list.size, list.size)


}


}

fun clearData() {

notifyItemRangeRemoved(0,data!!.size)


data?.clear()


}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {




Download 1.68 Mb.

Do'stlaringiz bilan baham:
1   ...   14   15   16   17   18   19   20   21   22




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling