[英]Android soft keyboard showing under a dialog fragment
I have a dialog fragment, which has a listview with mutiple views listed, in one of that view there is an edittext which has showing cursor, but soft keyboard is not showing. 我有一个对话框片段,其中有一个列出了多个视图的listview,在其中一个视图中,有一个edittext,其中显示光标,但未显示软键盘。 So i write a code on its onclick to show keyboard like below, 所以我在onclick上写了一个代码,以显示如下所示的键盘,
etcomment.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
InputMethodManager imm = (InputMethodManager) activity
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
});
Now keyboard is showing, but it is showing under that DialogFragment
现在正在显示键盘,但是它在该DialogFragment
下显示
I searched but didn't get an answer, please help me! 我搜索了但没有得到答案,请帮助我!
Your window params is the problem Okay u should do like this:.. 您的窗口参数是问题,好的,您应该这样做:
Dialog dialog = new Dialog(DialogTestKeyboard.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = 400;
lp.height = 800;
dialog.setContentView(yourLayoutHavingEditText);
dialog.setCancelable(false);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
dialog.show();
dialog.getWindow().setAttributes(lp);
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.