Android 安卓:焦点状态、启用状态、按下状态和选定状态之间有什么区别?
我看了看,想找出其中的差别,但不太明白。我只是部分理解了“选定”状态 有人能用一些具体的例子来解释这些区别吗?我希望我的问题不是很含糊。如果是的话,如果有人能帮我改进它就太好了,因为我不知道如何更清楚地问它Android 安卓:焦点状态、启用状态、按下状态和选定状态之间有什么区别?,android,view,Android,View,我看了看,想找出其中的差别,但不太明白。我只是部分理解了“选定”状态 有人能用一些具体的例子来解释这些区别吗?我希望我的问题不是很含糊。如果是的话,如果有人能帮我改进它就太好了,因为我不知道如何更清楚地问它 提前感谢。已启用->用户交互可能 已禁用->无法进行用户交互 如果将鼠标悬停在小部件上,则该小部件已聚焦 如果您在该小部件上按下(半点)按钮,它将被按下 如果在鼠标处于同一位置时按下向下键和向上键,则会选择 聚焦-(窗口,视图)是键盘事件的目的地(是的,有些机器人有物理键盘),有些机器人有
提前感谢。已启用->用户交互可能 已禁用->无法进行用户交互
- 如果将鼠标悬停在小部件上,则该小部件已聚焦
- 如果您在该小部件上按下(半点)按钮,它将被按下
- 如果在鼠标处于同一位置时按下向下键和向上键,则会选择
/**
* Changes the activated state of this view. A view can be activated or not.
* Note that activation is not the same as selection. Selection is
* a transient property, representing the view (hierarchy) the user is
* currently interacting with. Activation is a longer-term state that the
* user can move views in and out of. For example, in a list view with
* single or multiple selection enabled, the views in the current selection
* set are activated. (Um, yeah, we are deeply sorry about the terminology
* here.) The activated state is propagated down to children of the view it
* is set on.
*
* @param activated true if the view must be activated, false otherwise
*/
public void setActivated(boolean activated)
/**
* Dispatch a key event to the next view on the focus path. This path runs
* from the top of the view tree down to the currently focused view. If this
* view has focus, it will dispatch to itself. Otherwise it will dispatch
* the next node down the focus path. This method also fires any key
* listeners.
*
* @param event The key event to be dispatched.
* @return True if the event was handled, false otherwise.
*/
public boolean dispatchKeyEvent(KeyEvent event)
谢谢你的澄清!我仍然不清楚聚焦状态:在触摸屏上聚焦状态是如何工作的?它是这样的:当我在屏幕上移动手指时,我的手指在任何特定的时刻都在哪里,屏幕的那一部分有焦点?但是对于触摸输入,你通常只需要注意选择的状态,对吗@EnginYapici我认为文本字段在等待输入时是聚焦的。使用触摸输入时,您需要注意按下和选择的状态。如果触碰发生在小部件内部,而触碰发生在小部件外部,则不认为选择了触碰。实际上,“聚焦”也适用于触碰界面。如果屏幕上有多个重叠的半透明视图(例如片段),则所有桌面范例都适用。此外,新的安卓设备配备了接近传感器,即使没有鼠标,“悬停”也有意义。按下/选择启用/禁用是过于简单化了。嗯,是的,我们对这里的术语深表歉意。
/**
* Changes the activated state of this view. A view can be activated or not.
* Note that activation is not the same as selection. Selection is
* a transient property, representing the view (hierarchy) the user is
* currently interacting with. Activation is a longer-term state that the
* user can move views in and out of. For example, in a list view with
* single or multiple selection enabled, the views in the current selection
* set are activated. (Um, yeah, we are deeply sorry about the terminology
* here.) The activated state is propagated down to children of the view it
* is set on.
*
* @param activated true if the view must be activated, false otherwise
*/
public void setActivated(boolean activated)
/**
* Dispatch a key event to the next view on the focus path. This path runs
* from the top of the view tree down to the currently focused view. If this
* view has focus, it will dispatch to itself. Otherwise it will dispatch
* the next node down the focus path. This method also fires any key
* listeners.
*
* @param event The key event to be dispatched.
* @return True if the event was handled, false otherwise.
*/
public boolean dispatchKeyEvent(KeyEvent event)