--- title: "Navigation and Focus" slug: "navigation-and-focus-2" updated: 2025-08-05T21:35:03Z published: 2025-08-05T21:35:03Z canonical: "support.vuzix.com/navigation-and-focus-2" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.vuzix.com/llms.txt > Use this file to discover all available pages before exploring further. # Navigation and Focus ## **Overview** To allow your user interface to be controlled via the physical buttons, you must manually enable focus on the UI elements you wish to be reached by navigation. You must also control the focus order. These are accomplished using standard Android mechanisms that are summarized here for convenience. --- ## **Making UI Elements Focusable** The easiest way to make the UI easily navigated with the buttons is to explicitly define the focus rules in the layout XML. All UI elements including layouts should explicitly define android:focusable and android:focusableInTouchMode ```xml ``` --- ## **Default Focus in Java Code** You can also easily request focus of any UI element in your onCreate() method. ```java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button sampleButton = (Button) findViewById(R.id.firstButton); // It is a best practice to explicitly request focus to a specific UI // element to make navigation with the buttons more consistent to the user sampleButton.requestFocusFromTouch(); } ``` This makes the request to grab the focus as soon as the Activity is created. --- ## **Controlling Focus Order** Since the buttons are used to change focus between items, you may want to explicitly control the focus order. There are two ways to do this. You can specify this in the XML, or you can use java code. --- ## **Controlling Focus Order in the Layout XML** The XML attributes can define the focus order used to highlight buttons and views within the screen. The navigation buttons send left and right, so set the android:nextFocusLeft and android:nextFocusRight to valid elements. ```xml