android:imeOptions指定了弹出键盘时右下角的按键的显示文字
16lz
2021-12-04
android:imeOptions指定了弹出键盘时右下角的按键的显示文字,未指定时默认为回车图标。
android:imeOptions="flagNoExtractUi" //使软键盘不全屏显示,只占用一部分屏幕 同时,这个属性还能控件软键盘右下角按键的显示内容,默认情况下为回车键 android:imeOptions="actionNone" //输入框右侧不带任何提示 android:imeOptions="actionGo" //右下角按键内容为'开始' android:imeOptions="actionSearch" //右下角按键为放大镜图片,搜索 android:imeOptions="actionSend" //右下角按键内容为'发送' android:imeOptions="actionNext" //右下角按键内容为'下一步' android:imeOptions="actionDone" //右下角按键内容为'完成'
详细使用见 http://blog.csdn.net/caiwenfeng_for_23/article/details/37900503
当然也需要对这个按键进行设置点击事件:
editText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // do sth when pressed the enter key in the Soft InputMethod }});
但是在AlertDialog或这PoupWIndow的EditText当调用requestFocus()方法的时候却不会自动弹出键盘,
此时需要直接调用显示键盘命令,当editText获取焦点的时候。
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); //pop.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } }});
在必要的时候隐藏输入法界面:
//隐藏输入法界面((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(input.getWindowToken(), 0);
更多相关文章
- android EditText中inputType的属性列表
- EditText android:imeOptions与inputType="textMultiLine" 的坑
- android inputType属性
- android EditText中inputType的属性列表
- EditText 报出 “This text field does not specify an inputTyp
- Android查询:模拟键盘鼠标事件(adb shell 实现)
- 记录EditText的输入属性InputType以及imeOptions
- android:imeOptions
- android editText 软键盘enter键图标的设置