我们大家都知道通过指定EditText的android:imeOptions属性可以修改 输入法enter键的显示情况

例如:

android:imeOptions="actionNext"   下一个配合android:nextFocusForward属性一起使用

 android:imeOptions="actionSearch" 搜索

 android:imeOptions="actionDone" enter

 android:imeOptions="actionGo" 前往

如果我们单独只设置android:imeOptions这个属性的话,我们会悲剧的发现.输入法的enter键一直都不会有变化

例如:


而我们如果加上 android:inputType=""

然后随便指定一种输入类型.我们的imeOptions属性也就起作用了

所以使用的时候记得设置


在activity或者fragment来监听点击了enter go 或者 search

  1. edittext.setOnEditorActionListener(new TextView.OnEditorActionListener() {  
  2.               
  3.             @Override  
  4.             public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {  
  5.                 /*判断是否是“GO”键*/  
  6.                 if(actionId == EditorInfo.IME_ACTION_GO){  
  7.                     /*隐藏软键盘*/  
  8.                     InputMethodManager imm = (InputMethodManager) v  
  9.                             .getContext().getSystemService(  
  10.                                     Context.INPUT_METHOD_SERVICE);  
  11.                     if (imm.isActive()) {  
  12.                         imm.hideSoftInputFromWindow(  
  13.                                 v.getApplicationWindowToken(), 0);  
  14.                     }  
  15.                       
  16.                     edittext.setText("success");  
  17.                     webview.loadUrl(URL);  
  18.                       
  19.                     return true;  
  20.                 }  
  21.                 return false;  
  22.             }  
  23.         });  

记录一下,免得以后走坑

更多相关文章

  1. [Android]Android(安卓)manifest 属性说明
  2. 【转】Android(安卓)xml资源文件中@、@android:type、@*、?、@+含
  3. android软键盘右下角按键设置
  4. Android(安卓)xml资源文件中@、@android:type、@*、?、@+含义和区
  5. 在程序中设置android:gravity 和 android:layout_Gravity属性
  6. Android(安卓)xml资源文件中@、@android:type、@*、?、@+含义和区
  7. android布局属性的介绍
  8. Android新手笔记—六大布局
  9. android 布局属性

随机推荐

  1. [android]Activity切换动画
  2. Android(安卓)EGL_BAD_CONFIG error,配置E
  3. Android适配器之-----SimpleAdapter
  4. Android UI开发第二篇——多级列表(Expand
  5. android布局学习利器-Hierarchy Viewer
  6. Android中/system/build.prop文件解读
  7. Android进程内存上限
  8. Android开发之ConstraintLayout布局
  9. android常用知识(累计)
  10. Android系统自带主题的使用及自定义主题