I am new to android and I am using list view with one text view and button.I am performing some visibility stuff where after clicking on button1 it will hide the button1 and show button2.
Set visibility View.GONE and View.VISIBLE is working perfectly but problem is occurring when I scroll my list view magically it is reseting all button1 to View.VISIBLE state.
Please anyone help me to overcome with this problem.
Code:
@Override
public View getChildView(final int i, final int i1, boolean b, View
view, ViewGroup viewGroup) {
if(view == null) {
holder = new ViewHolder();
LayoutInflater parentInflater = (LayoutInflater) mctx.getSystemService(mctx.LAYOUT_INFLATER_SERVICE);
view = parentInflater.inflate(R.layout.itemname_child_layout, null);
} else {
holder = (ViewHolder) view.getTag();
}
holder.button1 = view.findViewById(R.id.button1);
holder.button1 = view.findViewById(R.id.button2);
//initial button state
holder.button1.setVisibility(View.VISIBLE);
holder.button1.setVisibility(View.GONE);
holder.recordBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
holder.button1.setVisibility(View.GONE);
holder.button2.setVisibility(View.VISIBLE);
}
}
view.setTag(holder);
return view;
}