php中文网 | cnphp.com

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 744|回复: 0

Adapter class for Recyclerview in kotlin android

[复制链接]

2627

主题

2634

帖子

9336

积分

管理员

Rank: 9Rank: 9Rank: 9

UID
1
威望
0
积分
6587
贡献
0
注册时间
2021-4-14
最后登录
2024-4-26
在线时间
667 小时
QQ
发表于 2022-3-24 11:18:15 | 显示全部楼层 |阅读模式
[mw_shl_code=applescript,true]class ClassName(val list:ArrayList<Type of your list>):RecyclerView.Adapter<ClassName.ViewHolder>() {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ClassName.ViewHolder {
        val v = LayoutInflater.from(parent.context).inflate(R.layout.item_layout, parent, false)
        return ViewHolder(v)
    }

    override fun getItemCount(): Int {
       return list.size
    }

    override fun onBindViewHolder(holder: ClassName.ViewHolder, position: Int) {
        holder.bindItems(list[position])
    }
    class ViewHolder(itemview: View):RecyclerView.ViewHolder(itemview)
    {

        fun bindItems(t: type of your list){

        }
    }
}[/mw_shl_code]
Adapter class for Recyclerview in kotlin android.txt (698 Bytes, 下载次数: 0)





上一篇:CSS Conic Gradient
下一篇:Validating a Date Format
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|php中文网 | cnphp.com ( 赣ICP备2021002321号-2 )51LA统计

GMT+8, 2024-4-27 00:03 , Processed in 0.195106 second(s), 39 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

申明:本站所有资源皆搜集自网络,相关版权归版权持有人所有,如有侵权,请电邮(fiorkn@foxmail.com)告之,本站会尽快删除。

快速回复 返回顶部 返回列表