默认情况下软键盘右下角的按钮为“下一个”,点击会到下一个输入框,保持软键盘
设置 EditView
android:imeOptions="actionDone" ,软键盘下方变成“完成”,点击后光标保持在原来的输入框上,并且软键盘关闭
android:imeOptions="actionSend" 软键盘下方变成“发送”,点击后光标移动下一个
etEmail.setOnEditorActionListener(
this
);
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
switch (actionId){
case EditorInfo.IME_NULL:
System.out.println( "null for default_content: " + v.getText() );
break ;
case EditorInfo.IME_ACTION_SEND:
System.out.println( "action send for email_content: " + v.getText());
break ;
case EditorInfo.IME_ACTION_DONE:
System.out.println( "action done for number_content: " + v.getText());
break ;
}
//Toast.makeText(this, v.getText()+"--" + actionId, Toast.LENGTH_LONG).show();
return true ;
}
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
switch (actionId){
case EditorInfo.IME_NULL:
System.out.println( "null for default_content: " + v.getText() );
break ;
case EditorInfo.IME_ACTION_SEND:
System.out.println( "action send for email_content: " + v.getText());
break ;
case EditorInfo.IME_ACTION_DONE:
System.out.println( "action done for number_content: " + v.getText());
break ;
}
//Toast.makeText(this, v.getText()+"--" + actionId, Toast.LENGTH_LONG).show();
return true ;
}
email.setImeOptions(
EditorInfo.IME_ACTION_DONE)
或者
<
EditText
android:text
=
""
android:id
=
"@+id/email_content"
android:layout_width = "fill_parent" android:layout_height = "wrap_content"
android:inputType = "text|textEmailAddress"
android:imeOptions = "actionSend" > </ EditText >
android:layout_width = "fill_parent" android:layout_height = "wrap_content"
android:inputType = "text|textEmailAddress"
android:imeOptions = "actionSend" > </ EditText >