星空网 > 软件开发 > 操作系统

Android App监听软键盘按键的三种方式与改变软键盘右下角确定键样式

actionNone : 回车键,按下后光标到下一行
actionGo : Go,
actionSearch : 放大镜
actionSend : Send
actionNext : Next
actionDone : Done,确定/完成,隐藏软键盘,即使不是最后一个文本输入框

 

android:singleline="true"

android:imeoptions="actionSearch"

 

EditText.setOnEditorActionListener设置监听

 

 

 @Override  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {    boolean isOK = true;    switch (actionId) {      case EditorInfo.IME_ACTION_NONE:        Toast.makeText(mContext, "点击-->NONE", Toast.LENGTH_SHORT).show();        break;      case EditorInfo.IME_ACTION_GO:        Toast.makeText(mContext, "点击-->GO", Toast.LENGTH_SHORT).show();        break;      case EditorInfo.IME_ACTION_SEARCH:        Toast.makeText(mContext, "点击-->SEARCH", Toast.LENGTH_SHORT).show();        break;      case EditorInfo.IME_ACTION_SEND:        Toast.makeText(mContext, "点击-->SEND", Toast.LENGTH_SHORT).show();        break;      case EditorInfo.IME_ACTION_NEXT:        Toast.makeText(mContext, "点击-->NEXT", Toast.LENGTH_SHORT).show();        break;      default:        isOK = false;        break;    }

 

 

<??><LinearLayout ="http://schemas.android.com/apk/res/android"  ="http://schemas.android.com/tools"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:orientation="vertical"  android:paddingBottom="@dimen/activity_vertical_margin"  android:paddingLeft="@dimen/activity_horizontal_margin"  android:paddingRight="@dimen/activity_horizontal_margin"  android:paddingTop="@dimen/activity_vertical_margin"  tools:context="com.edwin.demokeyboard.MainActivity">  <TextView    android:layout_width="match_parent"    android:layout_height="50dp"    android:gravity="center"    android:text="改变软键盘右下角确定键样式"    android:textSize="20sp" />  <EditText    android:id="@+id/et_main_one"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:hint="actionGo"    android:imeOptions="actionGo"    android:singleLine="true" />  <EditText    android:id="@+id/et_main_two"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:hint="actionSearch"    android:imeOptions="actionSearch"    android:singleLine="true" />  <EditText    android:id="@+id/et_main_three"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:hint="actionSend"    android:imeOptions="actionSend"    android:singleLine="true" />  <EditText    android:id="@+id/et_main_four"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:hint="actionNext"    android:imeOptions="actionNext"    android:singleLine="true" /></LinearLayout>

 

 

 

 Android App监听软键盘按键的三种方式与改变软键盘右下角确定键样式images/loading.gif' data-original="http://images2015.cnblogs.com/blog/695096/201607/695096-20160719171252497-486497918.gif" />

 

 

源码地址:




原标题:Android App监听软键盘按键的三种方式与改变软键盘右下角确定键样式

关键词:Android

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流