如何在一个TextView将焦点设置在活动开始时? [英] How to set focus on a TextView when an Activity starts?

查看:99
本文介绍了如何在一个TextView将焦点设置在活动开始时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个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.

这篇关于如何在一个TextView将焦点设置在活动开始时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆