android:nextFocusDown
You have to be careful about setting android:nextFocusDown in your XML layout because errors will be thrown if the objects you are referencing haven't been created yet. I ran into that situation, so I set the references programmatically.
In this instance, I have three side-by-side-by-side EditText objects inside of a RelativeLayout: et1, et2 and et3. Pressing the next button in et1 should focus et2. Pressing the next button in et2 should focus et3. Finally, a "Done" button is in place for et3 so we can stop there. The code to accomplish this is listed below:
// Get references to layout objects EditText et1=(EditText)findViewById(R.id.et1); EditText et2=(EditText)findViewById(R.id.et2); EditText et3=(EditText)findViewById(R.id.et3); // Set keyboard next buttons et1.setNextFocusDownId(R.id.et2); et2.setNextFocusDownId(R.id.et3);
Java lang Runtime Exception can produce when the view specified by id R.id.et2 are not exist or not visibile...
ReplyDeletegood
ReplyDelete