I have some code for the Item
of a GridView
.
The GridView
's Item
has LineareLayout
so that it must execute first and when the CheckBox
is clicked it should be visible. The LineareLayout
has two TextBox
es and when clicked on it the keyboard is shown to accept text input.
My adapter is:
public override View GetView(int position, View convertView, ViewGroup parent)
{
////set Gone in start
LinearLayout llToGone = convertView.FindViewById<LinearLayout>(Resource.Id.ll_add_count);
llToGone.Visibility = ViewStates.Gone;
////Handle checkbox
CheckBox chb = convertView.FindViewById<CheckBox>(Resource.Id.chb_prod);
chb.SetOnClickListener(new CheckBoxClick(context,llToGone));
}
public class CheckBoxClick :Java.Lang.Object, IOnClickListener
{
Activity act;
LinearLayout ll;
public CheckBoxClick(Activity ctx,LinearLayout l)
{
act = ctx;
ll = l;
}
public void OnClick(View v)
{
CheckBox ctv = (CheckBox)v;
if (ctv.Checked == true)
{
ll.Visibility = ViewStates.Visible;
}
else
{
ll.Visibility = ViewStates.Gone;
}
}
}
My problem happens when I click on the TextBox
to add the text and the keyboard is open:
the adapter is rerun and the CheckBox
is gone with checked="False"
.
Why does that happen and how to preserve the state of it?
Aucun commentaire:
Enregistrer un commentaire