I've seen in some applications that in the keyboard appears a Button called next that puts the focus on the next Edit Text. I want to add this in my application, Do you know how I can do it? Or it's only on the application's keyboard? Thanks a lot. Sorry, I haven't more information about this.
In the layout of edittext add android:imeOptions attribute. Here you can add different action buttons like Go, Search , Send , Next, Done etc. But to use this the EditText has to be a singleLine Else there will be an enter button there. So also use the android:singleLine="true".
setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (edtPasscode3. getText(). length() == 1) edtPasscode4. requestFocus(); return false; } });
Click on the "Plain Text" label, and drag it to your designer. If you click on the button below, you will see the xml code. The textbox is called EditText.
In the layout of edittext add android:imeOptions
attribute. Here you can add different action buttons like Go, Search , Send , Next, Done etc. But to use this the EditText has to be a singleLine Else there will be an enter button there. So also use the android:singleLine="true".
So here is your solution
<EditText
android:id=//put ur id
android:layout_width=//according to need
android:layout_height=//accordintoneed
android:imeOptions="actionNext"
android:singleLine="true"/>
EDIT
for addition i should add some more for future use or for the help of others..
You can handle the imeoption actions from your code. for that you have to set setOnEditorActionListener to the Edittext and when a action is pressed you can get it on public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
method. and if you not handle the code by yourself the imeoptions action will do the default action (usually going to next control).
Here is an example code for handling the action
EditText e = (EditText)findViewById(R.id.editText1);
e.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_NEXT ) {
// handle next button
return true;
}
return false;
}
});
You just have to use the imeOptions tag in your layout. See imeOptions in docu.
<EditText
android:id="@+id/someField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"/>
You have to add these two line given below in your EditText
android:imeOptions="actionNext"
android:singleLine="true"
i tried all those answers posted here but none actually work. gladly I found myself a solution for this.
<EditText
android:id="@+id/etRegisterFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Firstname"
android:imeOptions="actionNext"
android:inputType="textCapWords"
android:maxLines="1" />
<EditText
android:id="@+id/etRegisterLastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Lastname"
android:imeOptions="actionNext"
android:inputType="textCapWords"
android:maxLines="1" />
Please do notice that I ADD android:inputType. Thats it .
Cheers / Happy coding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With