首页 > 其他 > 详细

98、EditText 按键盘查询 触发事件

时间:2016-06-19 15:41:05      阅读:229      评论:0      收藏:0      [点我收藏+]

只需要在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”可以防止软键盘会把原来的界面挤上去的问题

98、EditText 按键盘查询 触发事件

原文:http://www.cnblogs.com/androidsj/p/5598106.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!