Hey guys,
In my app I have a set of EditText fields that each get populated from a database. Underneath these fields I have a button labeled 'Save Item' that is disabled by default until you start making changes to any of the fields above. I need to make it so that it fires my EnableSaveItemButton method no matter which EditText field you click on and start editing.
I know that I need it to respond to the AfterTextChanged property, but I only know how to make it work when there is just one field. I know I need to place all of my EditText fields into an array, but need help with that. Please see my code below:
EditText assetTypeText = null;
EditText modelText = null;
EditText manufacturerText = null;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view
SetContentView(Resource.Layout.Detail);
_imgView = FindViewById<ImageView>(Resource.Id.imageView1);
assetTypeText = FindViewById<EditText> (Resource.Id.assetTypeEditText);
modelText = FindViewById<EditText> (Resource.Id.modelEditText);
manufacturerText = FindViewById<EditText> (Resource.Id.manufacturerEditText);
manufacturerText.AfterTextChanged += delegate(object sender, Android.Text.AfterTextChangedEventArgs e) {
EnableSaveItemButton();
};
Button buttonSave = FindViewById<Button>(Resource.Id.Detail_SaveButton);
buttonSave.Enabled = false;
buttonSave.Click += delegate
{
//bla bla bla
}
//further below
public void EnableSaveItemButton ()
{
Button buttonSave = FindViewById<Button>(Resource.Id.Detail_SaveButton);
buttonSave.Enabled = true;
}
Any help is appreciated, thanks!