Usman Kurd Usman Kurd - 15 days ago 5
Android Question

Lose Focus on Moving Next Text Field using Text Switcher

i m Using TextSwitcher to Move to Next Text Field Automatically it moves to the next Field perfectly
but when cursor moves to the next field it still focus the Previous textfield
Code for this is following

public void textWatcher(){

pin.addTextChangedListener(new TextWatcher() {


@Override

public void onTextChanged(CharSequence s, int start, int before,

int count) {

if(pin.getText().toString().length()==1)

{


pin2.requestFocus();

pin.clearFocus();


}

}

@Override

public void beforeTextChanged(CharSequence s, int start, int count,

int after) {

// TODO Auto-generated method stub

}

@Override

public void afterTextChanged(Editable s) {

// TODO Auto-generated method stub



}

});
}


Any Suggestion help will be greatful
Regards
Usman Kurd

Answer
public void textWatcher(){
   pPin1.addTextChangedListener(new TextWatcher() {

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {


    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
      int after) {
     // TODO Auto-generated method stub

    }

    @Override
    public void afterTextChanged(Editable s) {
     if(pPin1.getText().toString().length()==1)
     {
      pPin2.requestFocus();
     }
     // TODO Auto-generated method stub

    }

   });
}

Please try this code.. It will work perfect.

Comments