tags:

views:

34

answers:

1

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(R.id.my_text_vew);
    myTextView.setFocusable(true);
    myTextView.setOnClickListener(this);
    myTextView.requestFocus();

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

Can anyone help?

Thanks.

+2  A: 

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.

Romain Guy
How to do the opposite. For example I have a numeric editfield as first ui object, and always receives focus and popups the keyboard. I don't want the keyboard to popup.
Pentium10
So, I need to set the TextView to be focusable in touch mode?