Android 如何在警报对话框中添加多个按钮

Android 如何在警报对话框中添加多个按钮,android,android-alertdialog,Android,Android Alertdialog,如何在警报对话框中添加第三个按钮?我在代码中使用了一个警报对话框,但我想在对话框中显示多个按钮 alertDialogBuilder .setMessage("Click yes to search on google") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick( DialogInterface dialog,

如何在警报对话框中添加第三个按钮?我在代码中使用了一个警报对话框,但我想在对话框中显示多个按钮

alertDialogBuilder
   .setMessage("Click yes to search on google")
   .setPositiveButton("Yes", new DialogInterface.OnClickListener()
   {
      public void onClick(
          DialogInterface dialog,
          int id) {
          // if this button is clicked, close current activity
          searchFor = contents;
          Intent viewSearch = new Intent(Intent.ACTION_WEB_SEARCH);
          viewSearch.putExtra(SearchManager.QUERY, searchFor);
          startActivity(viewSearch);
      }
   })
   .setNegativeButton("No", new DialogInterface.OnClickListener()
   {
     public void onClick(
          DialogInterface dialog,
          int id)
       {
         finish();
       }
   });
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();

如果使用默认样式,最多只能有3个按钮


使用自定义
视图
并执行
AlertDialog.Builder.setView(mycustomview)

如果使用默认样式,最多只能有3个按钮

使用自定义
视图
并执行
AlertDialog.Builder.setView(mycustomview)

首先是方法。这是最简单的一个。secodn one可以扩展额外的XML视图,然后可以添加任意数量的按钮

我还发现了这个,看起来很有趣。

首先是方法。这是最简单的一个。secodn one可以扩展额外的XML视图,然后可以添加任意数量的按钮


我还发现了这一点,这似乎很有趣。

还有一个neutra按钮,您可以将其设置为与设置负数和正数按钮相同的值Yup..setNeutralButton()是您想要的..还有一个neutra按钮,您可以将其设置为与设置负数和正数按钮相同的值Yup..setNeutralButton()是您想要的。。