i need help.
I wanted to change button visibility in any other item inside recyclerview to dissapear, so other button except item that i selected become invisible ...
The trigger is when item get clicked/selected then any other item's button goes invisible/gone except the one i clicked... how do i do that? im using Kotlin btw.
Here is where i want to implement it inside "if (!b)" (if possible) in onBindViewHolder:
holder.mainLayout.setOnClickListener {
if (!b){
b = true
holder.addsLayout.isVisible = true
} else {
b = false
holder.addsLayout.isVisible = false
}
}
Edit:
Here is my viewholder:
class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
val itemTitle: TextView = itemView.findViewById(R.id.itemTitleRecordLocal)
val itemDelete: Button = itemView.findViewById(R.id.recordlocalDelete)
val itemTranscribe: Button = itemView.findViewById(R.id.transcribelocalTxt)
val mainLayout: RelativeLayout = itemView.findViewById(R.id.recordlocalTitleDateLayout)
val addsLayout: RelativeLayout = itemView.findViewById(R.id.addsRecordLocalLayout)
}
I just updated my code earlier, so its not button anymore but layout, but i think its similar bcuz i just need to change the visibility.
- itemDelete and itemTranscribe are buttons that i want to hide, and i put it in addsLayout.
- mainLayout is the item where i need to click to be selected.