I am developing an android app (Android Studio). I want to implement Visibility GONE/VISIBLE in every row. In the image there are three recyclerView rows,
I want to do the following things :
There are two part in every row Heading & Details.
- When This Activity open all the rows details should hide.
- When I click on particular row , details of the row should appear by Visibility VISIBLE.
When i again click on row details should disappear by Visibility GONE.
Problem is : If i clicked on first row, Details of first row is showing and without hiding details of first row when click on next any row Heading. I have to click two times to show the details of the next row or Hide the details of next row.
Adapter Code :
int i = 0;
holder.salt_head_ll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
i++;
if (i % 2 == 1) {
holder.have_show_ll.setVisibility(View.VISIBLE);
holder.l1_arrow.setImageResource(R.drawable.down_arrow_black);
} else if (i % 2 == 0) {
holder.have_show_ll.setVisibility(View.GONE);
holder.l1_arrow.setImageResource(R.drawable.right_arrow_black);
}
}
});