Guruh: 314-17 Bajardi: Ne’matjonov A
Download 1.68 Mb.
|
Ne'matjonov Abduvohid
else->{
(holder as NewsViewHolder).bindData(data!!.get(position).listData) }
} } override fun getItemViewType(position: Int): Int { return data!![position].listData.type }
fun onItemClick(view: View,data:Any) }
var data: ArrayList var onItemClickListener: HomeAdapter.OnItemClickListener? ) :
RecyclerView.Adapter override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NewsItemViewHolder { var holder = NewsItemViewHolder( LayoutInflater.from(parent.context).inflate( R.layout.item_news, parent,
false ) ) return holder } override fun getItemCount(): Int = data.size override fun onBindViewHolder(holder: NewsItemViewHolder, position: Int) { holder.setData(data[position] as NewsData) holder.itemView.setOnClickListener { onItemClickListener?.onItemClick(holder.itemView,data[position] as NewsData) } }
var image: ImageView var title: TextView var description: TextView var type: TextView init {
image = itemView.image_news_item title = itemView.title_news_item description = itemView.description_news_item type = itemView.type_news_item }
image.setImageResource(data.image) title.text = data.title description.text = data.description type.text = data.type } } class SliderItemAdapter( var data: ArrayList var onItemClickListener: HomeAdapter.OnItemClickListener? ):RecyclerView.Adapter override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SliderItemViewHolder {
} override fun getItemCount(): Int=data.size override fun onBindViewHolder(holder: SliderItemViewHolder, position: Int) { holder.setData(data[position] as SliderData) holder.itemView.setOnClickListener { onItemClickListener?.onItemClick(holder.itemView,data[position] as SliderData) } }
var image:ImageView var title: TextView var description: TextView init {
image = itemView.image_slider_item title=itemView.title_slider_item description=itemView.description_slider_item }
image.setImageResource(data.image) title.text = data.title description.text = data.description }
} Download 1.68 Mb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling