1.布局文件中的edittext:设置属性

android:singleLine="true"android:imeOptions="actionSearch"

2.java文件中

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {            @Override            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {                if (i == EditorInfo.IME_ACTION_UNSPECIFIED) {                    Toast.maketext(this,"你点击了回车",Toast.LENGTH_SHORT).show();                    //隐藏软键盘                    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);                    imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);                }                return false;            }        });

更多相关文章

  1. android用于打开各种文件的intent
  2. Android--取得布局中指定控件的宽高
  3. android计算器布局(TableLayout)
  4. Delphi XE5 for android 调用Java类库必看的文件
  5. android带图片的AlertDialog和文件管理器(代码)

随机推荐

  1. android确定kernel使用的config文件
  2. 讨论会1:Android消息循环机制原理与实现
  3. Android控件TextView中ellipsize属性(设置
  4. Android(安卓)解析smi字幕
  5. Android 自定义Html标签
  6. 在android 6.0以上无法获取READ_PHONE_ST
  7. android在使用RecyclerView布局里的andro
  8. Android Wear 开发-创建第一个卡片
  9. android 实现QQ好友列表
  10. 解决一个Android Studio gradle的小问题