我正在尝试找到一种方法来锁定ListView中的用户(当使用D-Pad时)防止它失去焦点,允许用户仅通过ListView导航,直到显式调用“exit”。
有什么简单的方法可以做到这一点?
I'm trying to find a way to lock the user inside a ListView (When using the D-Pad) preventing it from losing focus, allowing the user to navigate only through the ListView until "exit" is explicitly called.
There's any easy way to do this?
最满意答案
找到了!
如果需要,只需在xml中设置这些参数即可:
android:id="@+id/myListView" android:nextFocusDown="@id/myListView" android:nextFocusForward="@id/myListView" android:nextFocusLeft="@id/myListView" android:nextFocusRight="@id/myListView" android:nextFocusUp="@id/myListView"当然myListView只是一个示例id,你可以将这种技术用于任何类型的View,它可以将焦点设置锁定到自身的任何方向。
然后将用户锁定在该视图内,直到视图消失或焦点以编程方式移动到另一个视图。
Found!
If you need this, it will be enough to set those parameters in xml:
android:id="@+id/myListView" android:nextFocusDown="@id/myListView" android:nextFocusForward="@id/myListView" android:nextFocusLeft="@id/myListView" android:nextFocusRight="@id/myListView" android:nextFocusUp="@id/myListView"Of course myListView is just an example id, and you could use this technique with any kind of View, it locks the focus setting the next focus to itself, in any direction.
The user is then locked inside that view until the view disappears or the focus is programmatically moved to another view.
更多推荐
发布评论