当前位置: 代码迷 >> Android >> AlertDialog的有关问题
  详细解决方案

AlertDialog的有关问题

热度:76   发布时间:2016-05-01 12:32:32.0
AlertDialog的问题
我现在AlertDialog中,有三个EditViet.他们三个都不能为空.
然后他们三个我都用了setError的方法提示.
但是每次我按了确定,然后对话框就消失了.这个问题怎么解决.
我想在其中一个为空的时候,点了确定,对话框还不消失,应该怎么解决呢?
------最佳解决方案--------------------

 new AlertDialog.Builder(this).setPositiveButton("a",
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            Field f = dialog.getClass().getSuperclass()
                                    .getDeclaredField("mShowing");
                            f.setAccessible(true);
                            f.set(dialog, false);// 不关闭
                            // f.set(dialog, true);关闭
                        }
                        catch(Exception e) {
                            // TODO: handle exception
                        }
                    }
                }).show();

------其他解决方案--------------------
2楼正解,印象中只有这种方法改变下属性才可以
------其他解决方案--------------------
引用:
2楼正解,印象中只有这种方法改变下属性才可以

俺是1楼,你才是二楼
------其他解决方案--------------------
引用:
引用:2楼正解,印象中只有这种方法改变下属性才可以
俺是1楼,你才是二楼

呵呵 打错了,抱歉 
------其他解决方案--------------------
这是用的反射?
------其他解决方案--------------------
引用:
这是用的反射?

这段代码也是百度的


不过LZ该结贴了,不喜欢提了问不接贴的人,搞得都木有回答问题的欲望了