EditText switches the enter key of the Input Method software to jump to the next EditText or search. edittextenter
First, the enter key of the Input Method software can be changed, and can be changed to next, search, and so on.
For example, implement a login interface
The Code is as follows:
<RelativeLayout
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent" android: paddingLeft = "@ dimen/activity_horizontal_margin"
Android: paddingRight = "@ dimen/activity_horizontal_margin"
Android: paddingTop = "@ dimen/activity_vertical_margin"
Android: paddingBottom = "@ dimen/activity_vertical_margin" tools: context = ". MainActivity"> <EditText
Android: id = "@ + id/et_username"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: hint = "username"
Android: imeOptions = "actionNext"
Android: nextFocusForward = "@ + id/et_password"
Android: singleLine = "true"
/>
<EditText
Android: id = "@ + id/et_password"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: hint = "password"
Android: imeOptions = "actionDone"
Android: layout_below = "@ id/et_username"
Android:NextFocusForward= "@ + Id/btn_login"
Android: singleLine = "true"
/>
<Button
Android: id = "@ + id/btn_login"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: text = "login"
Android: layout_below = "@ id/et_password"
/>
</RelativeLayout>
Android: imeOptions = "actionNext" // you can specify the enter function for the input method, actionNext-Next actionSearch, and so on.
Android: nextFocusForward = "@ + id/et_password"// Specify the focus of the next view
In this way, after you enter username, press the next step of the Input Method and you will be transferred to the password input box. (These two attributes are the attributes of the parent view, so)
After you enter the password, the EditText of the password has the attributeAndroid: imeOptions = "actionDone", you can also listen to it
The Code is as follows:
EditText etPassWord = (EditText) findViewById (R. id. et_password );
EtPassWord. setoneditexceptionlistener (new TextView. oneditexceptionlistener (){
@ Override
Public boolean oneditexception (TextView v, int actionId, KeyEvent event ){
If (actionId = EditorInfo. IME_ACTION_DONE ){
Toast. makeText (MainActivity. this, "Login", Toast. LENGTH_SHORT). show ();
//... Implement the login function
}
Return false;
}
});
This is my first technical blog. I hope you will like it and have some questions. I also hope you can communicate and make progress together.
There will be more articles on android technology in the future.