@Override
public void onBindViewHolder(final mainscreenspecializationadap.MyViewHolder holder, final int positionz) {
this.position = holder.getAdapterPo
Here is the solution for your requirement
public class AdapterClass extends RecyclerView.Adapter {
private int selected_position = -1;
@Override
public void onBindViewHolder(AdapterClass.ViewHolder holder, final int position) {
if (selected_position == position) {
// do your stuff here like
//Change selected item background color and Show sub item views
} else {
// do your stuff here like
//Change unselected item background color and Hide sub item views
}
// rest of the code here
holder.linelayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(selected_position==position){
selected_position=-1;
notifyDataSetChanged();
return;
}
selected_position = position;
notifyDataSetChanged();
}
});
//rest of the code here
}
}