android:imeOptions指定了弹出键盘时右下角的按键的显示文字
16lz
2021-01-23
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查询:模拟键盘鼠标事件(adb shell 实现)
- android editText 软键盘enter键图标的设置
- 很实用的android按键处理
- Android平台开发-Android keypad map-Android按键识别及映射过程
- Android模拟、实现、触发系统按键事件的方法
- android 日期时间格式转换;软键盘显示消失;获取系统title
- Android按键消息传播流程
- 【按键】灭屏后瞬间按返回键,可以点亮屏幕
- Android软键盘手动显示、隐藏、布局上移和EditText上移