Aalap Patel
Aalap Patel

Reputation: 2076

requestFocus() method not working for edittext

I have an 2 edit texts, one of them is visible and other is not. I have set visibility "gone" for the invisible one. Now when I click input method next from edittext one, I make edittext two visible and request focus there, it gets visible but focus is not there. Interesting thing is I made visibility "invisible" instead of "gone". here is the code...

 option1.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if(actionId == EditorInfo.IME_ACTION_NEXT){                   
                option2.setVisibility(View.VISIBLE);
                option2.requestFocus();                   
            }
            return false;
        }
    });

Upvotes: 0

Views: 1254

Answers (1)

Nainal
Nainal

Reputation: 1748

I am not sure it will work or not. But your setOnEditorActionListener() is returning false, make it to return true.

Upvotes: 1

Related Questions