How to Set Focus to a TextView, using requestFocus, in Java
requestFocus() added in API Level 1Sets focus to a TextView using requestFocus, in Java
1. Find a TextView using ID
<TextView
...
android:focusable="true"
android:focusableInTouchMode="true"
/>
3. In the MainActivity.java file, add the code below in the onCreate method.
...
myTextView.requestFocus();
4. Compile and run!
Related Articles:
- setSelected(true) - Set Focus to a TextView, using Java
- android:state_selected - Set Focus to a TextView, using state_selected, in XML
http://stackoverflow.com/questions/2150656/how-to-set-focus-on-a-view-when-a-layout-is-created-and-displayed