android触发立即显示软键盘及隐藏软键盘

首先是点击触发是软键盘弹出

private CommentAdapter.OnItemClickListener OnItemClickListener = new CommentAdapter.OnItemClickListener() {
@Override
public void onItemClick(int position) {
comment_layout.setVisibility(View.VISIBLE);
comment_add.setFocusableInTouchMode(true);
comment_add.setFocusable(true);
comment_add.requestFocus();
InputMethodManager inputManager =
(InputMethodManager)comment_add.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(comment_add, 0);

}
};

使用完毕后输入框隐藏,软键盘隐藏,最好使用

comment_layout.setVisibility(View.GONE);
InputMethodManager inputmanger = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
隐藏软键盘,完美解决
posted @ 2018-12-27 15:14  轩钰儿  阅读(359)  评论(0编辑  收藏  举报