本例橫向顯示UI控制項,並使用了nextFocusRight 明確為Button 指定按右鍵時下一個擷取焦點的UI控制項為rightButton (跳過中間的Button),但是從右至左時還是按照預設順序。
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_height=”wrap_content”
android:layout_width=”match_parent”
android:orientation=”horizontal”>
<Button android:id=”@+id/leftButton”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”3dip”
android:text=”@string/focus_2_left”
android:nextFocusRight=”@+id/rightButton”/> <!– jump over middle! –>
<Button android:id=”@+id/centerButton”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”3dip”
android:text=”@string/focus_2_jump” />
<Button android:id=”@+id/rightButton”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”3dip”
android:text=”@string/focus_2_right”/>
</LinearLayout>
作者:mapdigit