setSelected(true) - Set Focus to a TextView, using Java

How to Set Focus to a TextView, using Java

added in API Level 1

Set the focus to a TextView using Java.

1. Find the TextView by using findViewById.

2. In the MainActivity.java file, add the code below to the onCreate method.

myTextView.setSelected(true); 

3. Compile and run!

Related Articles: