First of all, the input method software can be changed, you can change the 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"//This property can specify the function of Input method Enter, Actionnext-next actionsearch and so on
android:nextfocusforward= "@+id/et_password" //Specify the next view to get focus
So when you enter username, press the next step of the input method, you will be transferred to the password input box. (This two attribute is the attribute of the parent view, so)
When you lose the password, password edittext has the attribute android:imeoptions= "Actiondone", you can also implement it to listen to it
The code is as follows:
EditText Etpassword = (EditText) Findviewbyid (R.id.et_password);
Etpassword.setoneditoractionlistener (New Textview.oneditoractionlistener () {
@Override
public boolean oneditoraction (TextView v, int ActionId, keyevent event) {
if (ActionId = = Editorinfo.ime_action_done) {
Toast.maketext (Mainactivity.this, "Login", Toast.length_short). Show ();
//... Implementing the Login function
}
return false;
}
});
This is my first published technology blog, I hope you like, what is the problem, but also hope that we have a lot of exchanges and common progress.
There will be more articles on Android technology in the future.
EditText switch the input key of IME software, realize jump to next edittext or search etc.