Created
August 24, 2022 06:59
-
-
Save mym0404/4ccb0ae9a18ef2fde3a88764c2067c8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class **$NAME$**Adapter : RecyclerView.Adapter<**$NAME$**Adapter.Holder>() { | |
private var items: List<**$DATA$**> = listOf() | |
fun submitList(items: List<**$DATA$**>) { | |
this.items = items | |
notifyDataSetChanged() | |
} | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder { | |
val inflater = LayoutInflater.from(parent.context) | |
val binding = Item**$NAME$**Binding.inflate(inflater, parent, false) | |
return Holder(binding) | |
} | |
override fun getItemCount() = items.size | |
override fun onBindViewHolder(holder: Holder, position: Int) = holder.bind(items[position]) | |
class Holder(private val binding: Item**$NAME$**Binding) : RecyclerView.ViewHolder(binding.root) { | |
fun bind(item:**$DATA$**) { | |
**$END$** | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment