android - determine which EditText field is selected on focus -


i have table multiple rows, each containing edittext corresponds dimension. want have sort of listener return whichever edittext selected. can done getcurrentfocus(); or onfocuschange();?

my idea have user select/focus dimension field want edited, , completing field using output slope/angle device's gyroscope when "write data" button pressed. i'd using selected_dimension_edittext.settext(gyro_value);

you can know edittext has focus id of view this:

    edittext edtext1 = (edittext)findviewbyid(r.id.edittext1);     edittext edtext2 = (edittext)findviewbyid(r.id.edittext2);      onfocuschangelistener mfocuschangelistener = new onfocuschangelistener() {          @override         public void onfocuschange(view v, boolean hasfocus) {             // todo auto-generated method stub             if(hasfocus){ //check if view has focus                 switch (v.getid()){                     case r.id.edittext1: {                         //code                     } break;                     case r.id.edittext2: {                         //code b                     } break;                 }             }         }     };      edtext1.setonfocuschangelistener(mfocuschangelistener);     edtext2.setonfocuschangelistener(mfocuschangelistener); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -