如何在一个TextView将焦点设置在活动开始时?焦点、如何在、TextView

2023-09-04 13:01:35 作者:昔梦

有一个EditText,在我的活动一个TextView。我想在TextView的焦点设置在活动启动时。我用下面的code:

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();

不过,code不起作用。在EditText上始终获得焦点活动开始时。

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

谁能帮助?

感谢。

推荐答案

在使用触摸屏启动活动这是预期。当在触控模式,只有一对夫妇的意见(的EditText和ListView)都可以接收焦点。如果您使用的轨迹球启动应用程序,你会看到重点的TextView。你们看到的是正确的和预期的结果。

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.