user256239 user256239 - 1 year ago 101
Android Question

How to set focus on a TextView when an Activity starts?

There are an EditText and a TextView in my Activity. I want to set focus on the TextView when the Activity starts. I used the following code:

TextView myTextView = (TextView) findViewById(;

But the code doesn't work. The EditText always receives focus when the activity starts.

Can anyone help?


Answer Source

This is expected when you start the Activity using the touch screen. When in "touch mode," only a couple of Views (EditText and ListView) can receive the focus. If you start your application using the trackball you will see the focus on the TextView. What you are seeing is the correct and expected result.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download