2011-04-01 131 views
0

我用下面的代码显示在Android上的警报,自定义警报内的警报在android中显示错误?

点击是的,我需要显示另一个警报后,

,但我会显示错误。我使用的代码如下所示,

authalert.setTitle("Save Video"); 
    authalert.setMessage("Do you want to save this Video?"); 
    authalert.setPositiveButton("Yes", new OnClickListener() { 
       @Override 
       public void onClick(DialogInterface dialog, int which) { 


    LayoutInflater li = LayoutInflater.from(getBaseContext()); 
       View forgotPasswordView =li.inflate(R.layout.forgotpopup, null); 


    AlertDialog.Builder forgotPasswordBuilder = new AlertDialog.Builder(getBaseContext()); 
       forgotPasswordBuilder.setTitle("Forgot Password"); 
       forgotPasswordBuilder.setView(forgotPasswordView); 
    final AlertDialog forgotPasswordDetail = forgotPasswordBuilder.create(); 
       forgotPasswordDetail.show(); 
            } 
            }); 

下面的错误,我得到,


04-01 11:33:28.708: ERROR/global(3440): java.lang.UnsupportedOperationException 
04-01 11:33:28.708: ERROR/global(3440):  at java.lang.VMThread.stop(VMThread.java:85) 
04-01 11:33:28.708: ERROR/global(3440):  at java.lang.Thread.stop(Thread.java:1379) 
04-01 11:33:28.708: ERROR/global(3440):  at java.lang.Thread.stop(Thread.java:1344) 

任何人提供一些建议,以恢复这一点。

+0

你是通过代码并找到有问题的功能吗? – rajath 2011-04-01 06:21:35

+0

您不应该使用getBaseContext()(根据Android开发人员),请尝试使用getApplicationContext()。你也只在日志中看到这个异常吗? – Karan 2011-04-01 06:48:05

回答

0

移动代码 LayoutInflater li = LayoutInflater.from(getBaseContext()); 查看forgotPasswordView = li.inflate(R.layout.forgotpopup,null);

AlertDialog.Builder forgotPasswordBuilder = new AlertDialog.Builder(getBaseContext()); forgotPasswordBuilder.setTitle(“忘记密码”); forgotPasswordBuilder.setView(forgotPasswordView); 最后AlertDialog forgotPasswordDetail = forgotPasswordBuilder.create();

要创建()类,并且在alert中调用forgotPasswordDetail.show(),它的工作正常。