Android Dialog弹出时的软键盘弹出问题

在项目开发中遇见了Dialog弹出后软键盘死活不弹出的问题,只不过已经解决了。。。


content是Dialog中的EdiText,必须在Dialog初始化完成后,才能够弹出来
LayoutInflater inflater = LayoutInflater.from(context);
LinearLayout inflate = (LinearLayout) inflater.inflate(R.layout.mydialog, null);
mDialog=new Dialog(context);
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mDialog.addContentView(inflate, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
TextView name = (TextView) inflate.findViewById(R.id.name_mydialog);
final EditText content= (EditText) inflate.findViewById(R.id.content_mydialog);
TextView cancle= (TextView) inflate.findViewById(R.id.cancle_mydialog);
TextView sure= (TextView) inflate.findViewById(R.id.sure_mydialog);
content.setFocusable(true);
content.setFocusableInTouchMode(true);
content.requestFocus();

content.post( new Runnable() {
@Override
public void run() {
InputMethodManager inputMethodManager=(InputMethodManager)((Activity) context ). getSystemService(Context. INPUT_METHOD_SERVICE );
inputMethodManager.toggleSoftInput( 0 , InputMethodManager. HIDE_NOT_ALWAYS );
}
});

你可能感兴趣的:(Android Dialog弹出时的软键盘弹出问题)