Android是否有任何属性或方法可以用来使用KeyPad给导航顺序



在我的应用程序中,我有7个按钮使用相对布局对齐。我显示按钮的顺序如下,

    one  Two
         Three
    Four Five
    Five Six

在上面的布局中,2,3,5,6是setClickable(false)。

1、4、5为启用状态。

现在当我按下键盘的向下箭头键来导航按钮时,"1"正在聚焦。接下来,如果我再次按下箭头键,我希望按钮"四"应该聚焦,而不是按钮"二"。

Android有任何属性或方法可以用来给这个导航顺序吗?如果不是,我可以使用什么最佳逻辑来实现它?

(我认为逻辑是,

)
    1. Override the keyDown event 
    2. On down arrow key press event see the button "One" is focussed or not
           --> if not set the focus to it
    3. else check the button "Four" is focussed or not --> if not set the focus to it

等等……

但似乎我把事情弄复杂了…)

谢谢

我使用setNextFocus…方法,它完成了工作。

setNextFocusDown文档

最新更新