Ayden
10/09/2020, 10:14 AMViewHolder class which in charges of populating the data to the quote_list.xml.
I create a setOnClickListener on the ViewHolder which would call a QuoteFragment that populated the relevant data into it.
May I know how to populate the data from the ViewHolder to the QuoteFragment ?
inner class QuoteViewHolder(private val bindingQuoteListBinding: QuoteListBinding) :
RecyclerView.ViewHolder(bindingQuoteListBinding.root) {
fun bind(quote: Quote) {
// Assign data to the textview
bindingQuoteListBinding.tvQuote.text = quote.quote
bindingQuoteListBinding.tvAuthor.text = quote.author ?: "None"
bindingQuoteListBinding.cardQuote.setOnClickListener {
val activity = it.context as AppCompatActivity
val fragment = QuoteFragment()
fragment.show(activity.supportFragmentManager, "TAG")
}
}
}alex_vinz
10/09/2020, 11:52 AMalex_vinz
10/09/2020, 11:52 AMMatthew Laser
10/09/2020, 1:09 PMAfzal Najam
10/09/2020, 5:25 PMView.OnClickListener in the ViewHolder and use itemView.setOnClickListener(this) in the init block