I have a ViewFlipper with several LinearLayout with EditTexts; after pressing a button, there's some validation done, and should it开发者_开发技巧 fail, I need to set the focus to the Edit that needs to be modified. vf is the ViewFlipper; et123 is an EditText. When there's an error detected, the following is executed:
vf.setDisplayedChild(5);
findViewById(R.id.et123).requestFocus();
The funny thing is that the first time the button is pressed, the focus goes to another element in the right Layout. If I press the button one more time, the focus goes to et123.
Any ideas on why does it happen or how to fix it?
Thanks
You might need to call
findViewById(R.id.et123).setFocusableInTouchMode(true);
Before calling requestFocus() to enable receiving focus.
加载中,请稍侯......
精彩评论