只需要在XML在输入框中加入Android:imeOptions=”actionSearch”,调用软键盘时,回车键就会显示搜索二字。

editSearch.setOnEditorActionListener(new editActionListener());
class editActionListener implements TextView.OnEditorActionListener {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {
            ((InputMethodManager) editSearch.getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(
                            mActivity.getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);

            这里可以操作你要的东东。。。。。。。return true;
        }
        return false;
    }
}

 

在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode=”adjustPan”可以防止软键盘会把原来的界面挤上去的问题

相关文章:

  • 2022-12-23
  • 2021-08-08
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-07
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
相关资源
相似解决方案