Android中Dialog中自定义EditView导致软键盘无法弹出

1 自定义界面XML



    
    
    
    
2 创建Dialog

 AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
                builder.setView(view);
                View view=View.inflate(mContext,R.layout.add_view,null);
                 EditText editText= (EditText) view.findViewById(R.id.my_query);
                CheckBox checkBox= (CheckBox) view.findViewById(R.id.is_checked);
                Button commitBt= (Button) view.findViewById(R.id.commit_query);
                Button button= (Button) view.findViewById(R.id.commit_query);
                Dialog dialog= builder.create();
                dialog.show();
                dialog.setContentView(view);
                dialog.getWindow().setLayout(300, ViewGroup.LayoutParams.WRAP_CONTENT);
                dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
添加
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
这一行代码后,重新显示软键盘。


你可能感兴趣的:(Android)