android:focus,enabled,pressed和selected状态有什么区别?

我看了http://developer.android.com/reference/android/view/View.html找出差异,但不明白。 我只是部分地理解了“select”状态。

有人可以用一些可靠的例子来解释这种差异吗? 我希望我的问题不是很模糊。 如果是这样,如果有人帮助我改进它,那将是非常好的,因为我不知道如何更清楚地提出这个问题。

先谢谢你。

启用 – >用户交互可能。

禁用 – >用户交互不可能。

  • 如果你把鼠标hover在一个小部件上,它将被聚焦
  • 如果您在该小部件上按下(半按),它将被按下
  • 如果在鼠标位于相同的位置时按下并按下,则会被选中

重点 – (窗口,视图)是键盘事件的目的地(是的,一些Android有物理键盘),有些则具有“除臭球”,产生向左右键盘快捷键。

激活 – 被激活的小部件(视图)。 例如,在多选列表中,选定的视图被激活。 我相信API 11中这个额外阶段的必要性是由于激活了包含checkbox的多选。 因此,select和检查的状态需要分开。

选中 – 仅适用于checkbox和其他可选视图。

View状态的完整列表是(StateSet id在左边,标志在右边):

R.attr.state_window_focused, VIEW_STATE_WINDOW_FOCUSED, R.attr.state_selected, VIEW_STATE_SELECTED, R.attr.state_focused, VIEW_STATE_FOCUSED, R.attr.state_enabled, VIEW_STATE_ENABLED, R.attr.state_pressed, VIEW_STATE_PRESSED, R.attr.state_activated, VIEW_STATE_ACTIVATED, R.attr.state_accelerated, VIEW_STATE_ACCELERATED, R.attr.state_hovered, VIEW_STATE_HOVERED, R.attr.state_drag_can_accept, VIEW_STATE_DRAG_CAN_ACCEPT, R.attr.state_drag_hovered, VIEW_STATE_DRAG_HOVERED 

另请参阅:

 /** * 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)