自定义警报内的警报显示android中的错误?

时间:2011-04-01 06:04:25

标签: android android-widget

我使用以下代码在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)

任何人都有一些建议来恢复这个。

1 个答案:

答案 0 :(得分: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);      final AlertDialog forgotPasswordDetail = forgotPasswordBuilder.create();

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