android editText 软键盘enter键图标的设置
2015-11-03 17:52
351 查看
EditText通过设置android:imeOptions来改变默认的”文本或者样式。这里举几个常用的常量值:
actionUnspecified 未指定,对应常量EditorInfo.IME_ACTION_UNSPECIFIED.
actionNone 没有动作,对应常量EditorInfo.IME_ACTION_NONE
actionGo 去往,对应常量EditorInfo.IME_ACTION_GO
actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH
actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND
actionNext 下一个,对应常量EditorInfo.IME_ACTION_NEXT
actionDone 完成,对应常量EditorInfo.IME_ACTION_DONE
事件监听:
actionUnspecified 未指定,对应常量EditorInfo.IME_ACTION_UNSPECIFIED.
actionNone 没有动作,对应常量EditorInfo.IME_ACTION_NONE
actionGo 去往,对应常量EditorInfo.IME_ACTION_GO
actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH
actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND
actionNext 下一个,对应常量EditorInfo.IME_ACTION_NEXT
actionDone 完成,对应常量EditorInfo.IME_ACTION_DONE
<EditText android:layout_marginTop="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="输入单位" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:singleLine="true" android:imeOptions="actionSearch" />
事件监听:
companySearchET.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { final String searchStr = companySearchET.getText().toString().trim(); if (actionId==EditorInfo.IME_ACTION_SEARCH ||(event!=null&&event.getKeyCode()== KeyEvent.KEYCODE_ENTER)) { //do something; if(searchStr == null || "".equals(searchStr)){ Toast.makeText(CompanyChangeActivity.this, "请输入单位关键字", Toast.LENGTH_SHORT).show(); Log.e("这里", "这里"); return true; }else{ } return true; } return false; } });
相关文章推荐
- Android Studio快捷键
- Android中Spinner控件的使用(十)
- Android启动页面制作
- Android开发自学笔记(Android Studio) 目录
- 第二章 安卓基础学习
- 解决Android studio 启动报错java.lang.RuntimeException: java.lang.IllegalArgumentException
- Android之Activity的几种跳转方式
- Android上跑单元测试
- Android系统集成Google Maps和Google Search apk注意事项
- 安卓开发中的双日期选择控件(可隐藏日,只显示年月)
- Android TouchEvent事件传递机制
- android 修改project package name
- android studio 所打开的,所有文件的标题栏没有了,或者是被移动了,完美解决方案。
- 自定义Android软键盘enter事件
- Android中DrawerLayout控件的使用
- android防止搜索按钮连续点击加载多次数据
- AndroidStudio项目上传到SVN中需要忽略的文件
- Android_shape分析
- 安卓动态获取及更改view的长宽
- Android浏览图片,点击放大至全屏效果