How to Set Next Focus to a TextView/EditText
android:nextFocusDown was added in API Level 1Defines the next view to give focus to when the next focus is FOCUS_Down. If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RunTimeException will result when the reference is accessed.
When the user presses the NEXT button or TAB key on the soft keyboard, this attribute will be invoked.
1. Add 2 TextViews in your main.xml file.
2. Set the android:id of the first TextView to mySecondFocus, and the second TextView to myFirstFocus.
3. In the main.xml file, in the first TextView, add the code below.
<TextView
...
android:nextFocusDown = "@+id/myFirstFocus"
/>
4. In the second TextView, add the code below.
<TextView
...
android:nextFocusDown = "@+id/mySecondFocus"
/>
5. This will make the second TextView displayed on the screen the first focus, and the first TextView the second focus.
Related Articles:
- android:nextFocusForward - Set Next Focus to TextView/EditText
- android:nextFocusRight - Set the Next Focus Right to a TextView/EditText
- android:nextFocusUp - Set Next Focus Up to a TextView/EditText
- android:focusableInTouchMode - How toDeny Focus to an Edittext
- android:focusable - Deny Focus to an EditTex
- Select All Text in an EditText on Focus
http://developer.android.com/reference/android/view/View.html#attr_android:nextFocusDown
http://developer.android.com/reference/android/R.attr.html#nextFocusDown
http://developer.android.com/guide/topics/ui/ui-events.html
http://stackoverflow.com/questions/5048586/can-you-set-tab-order-in-xml-layout
Other Resources http://developer.android.com/reference/android/R.attr.html#nextFocusDown
http://developer.android.com/guide/topics/ui/ui-events.html
http://stackoverflow.com/questions/5048586/can-you-set-tab-order-in-xml-layout