focusable和focusableInTouchMode之间的区别? [英] Difference between focusable and focusableInTouchMode?

查看:203
本文介绍了focusable和focusableInTouchMode之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道他们之间的实际区别...什么时候应该被使用,每个人应该如何使用,并在哪些情况下有帮助?

给出一些例子,并详细解释它们。

解释方法

http://android-developers.blogspot.co.at/2008/12/touch-mode.html



以下引号应该清楚:


模式是一件非常容易理解的事情,因为它只是表示上次用户交互是否使用触摸屏进行的。例如,如果您使用的是G1手机,则使用轨迹球选择小部件将使您脱离触摸模式;

.. 。


在触摸模式下,没有焦点和选择。只要用户输入
触摸模式,网格列表中的任何选定项目
就会被取消选中。同样,当
用户进入触摸模式时,任何关注的小部件都将变得不重视。


...


现在你知道焦点在触摸模式下不存在了,我必须解释它并不完全正确。焦点可以存在于触摸模式中,但是以非常特殊的方式,这个特殊的模式是为接收文本输入的小部件创建的,比如EditText,或者在启用过滤时使用ListView。

...


触摸模式是一个属性,您可以从代码或XML自己设置
。但是,它应该谨慎使用,并且只能在
非常特定的情况下使用,因为它会破坏与Android正常
行为的一致性。游戏就是一个很好的例子,它可以使得
在触摸模式属性中可以很好的利用可聚焦的特性。如果在
fullscreen中使用MapView,则MapView是另一个很好的例子,您可以在
中正确使用触摸模式中的focusable。



I want to know the actual difference between them... When should each be used, how should each be used, and in which situations is each helpful?

Give some examples and explain them in detail.

解决方案

It is explained in the Android Developers Blog: http://android-developers.blogspot.co.at/2008/12/touch-mode.html

The following quotes should make it clear:

By itself, the touch mode is something very easy to understand as it simply indicates whether the last user interaction was performed with the touch screen. For example, if you are using a G1 phone, selecting a widget with the trackball will take you out of touch mode;

...

In touch mode, there is no focus and no selection. Any selected item in a list of in a grid becomes unselected as soon as the user enters touch mode. Similarly, any focused widgets become unfocused when the user enters touch mode.

...

Now that you know focus doesn't exist in touch mode, I must explain that it's not entirely true. Focus can exist in touch mode but in a very special way we call focusable in touch mode. This special mode was created for widgets that receive text input, like EditText or, when filtering is enabled, ListView.

...

Focusable in touch mode is a property that you can set yourself either from code or XML. However, it should be used sparingly and only in very specific situations as it breaks consistency with Android normal behavior. A game is a good example of an application that can make good use of the focusable in touch mode property. MapView, if used in fullscreen as in Google Maps, is another good example of where you can use focusable in touch mode correctly.

这篇关于focusable和focusableInTouchMode之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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