安卓中Alertdailog中含有EditText不能输入解决办法

来源:互联网 发布:java开发网页小游戏 编辑:程序博客网 时间:2024/05/17 02:32


使用alertdailog来实现用户登录的时候,发现EditText无法打开软件盘,


上原代码


AlertDialog.Builder builder = new AlertDialog.Builder(context);final AlertDialog dialog = builder.create();View v = LayoutInflater.from(context).inflate(R.layout.dailog_login, null);Button regist = (Button) v.findViewById(R.id.dailog_login_btn_regist);dialog.show();dialog.getWindow().setContentView(v);

效果图



效果不错,但是不会弹出软件盘面


修改代码


AlertDialog.Builder builder = new AlertDialog.Builder(context);final AlertDialog dialog = builder.create();View v = LayoutInflater.from(context).inflate(R.layout.dailog_login, null);Button regist = (Button) v.findViewById(R.id.dailog_login_btn_regist);//注意下面这句话dialog.setView(((Activity)context).getLayoutInflater().inflate(R.layout.dailog_login, null));dialog.show();dialog.getWindow().setContentView(v);


效果图




ok,问题解决




1 0