0

ユーザーが何かを入力すると、次の編集テキストに自動的に移動します。onTextchanged を使用すると正常に動作しますが、ユーザーが戻るボタンを入力すると自動的に前の編集テキストに移動し、何かを入力すると次の編集テキストに移動するように、後方に移動する必要があります。どうすればできますか。誰か助けてください。

どんな助けでも大歓迎です。

editText_Pin1.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start,int before, int count) {
                if(editText_Pin1.getText().toString().length()==1) {    //size as per your requirement {
                    editText_Pin2.requestFocus();
                }

            }
            public void beforeTextChanged(CharSequence s, int start,int count, int after) {

            }
            @Override
            public void afterTextChanged(Editable arg0) {

            }
         });
4

3 に答える 3

1

このようなものを試してみてください...

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
            if(editText_Pin2.getText().toString().length()==1){//Here you will check the last editField which has lenght == 1 
                        editText_Pin1.requestFocus();
                        return false;//This will make sure your activity doesn't gets finished
            }
       }
        return super.onKeyDown(keyCode, event);
    }

お役に立てれば..

于 2013-05-22T11:43:06.227 に答える