我是Android开发的新手。我在android:imeOptions = "actionDone|flagNoExtractUi"
中使用EditText
,并在软键盘上将“完成”文本更改为“登录”。单击软键盘的登录Button
时如何执行某些操作?
答案 0 :(得分:0)
例如,您创建了方法
public void OnClickButton(View v)
{
/*
.
.
.
*/
}
现在,在按钮标记的layout.xml文件中添加
android:onclick="OnClickButton"
在这里你去......
答案 1 :(得分:0)
答案 2 :(得分:0)
尝试这个代码......
ed.setSingleLine(true);
ed.setHint("search places");
ed.setTextSize(16);
ed.setImeActionLabel("NAME YOU WANT TO GIVE FOR DISPLAY", EditorInfo.IME_FLAG_NAVIGATE_NEXT);
ed.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
ed.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if (event != null && event.getAction() != KeyEvent.ACTION_DOWN) {
return false;
}
else if (actionId == EditorInfo.IME_ACTION_SEARCH
|| actionId == EditorInfo.IME_ACTION_DONE|| event == null
|| event.getAction() == KeyEvent.ACTION_DOWN
&& event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(
ed.getWindowToken(), 0);
//DO YOUR WORK HERE .....
return true;
}
return false;
}
});