requestFocus - Set Focus to a TextView, using requestFocus, in Java

How to Set Focus to a TextView, using requestFocus, in Java

requestFocus() added in API Level 1

Sets focus to a TextView using requestFocus, in Java

1. Find a TextView using ID

2. Add focusable attributes below to the TextView, to enable requestFocus to work.

<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:
Resources:
http://stackoverflow.com/questions/2150656/how-to-set-focus-on-a-view-when-a-layout-is-created-and-displayed