如何在Android中向AlertDialog添加10个按钮?
我正在尝试创建一个包含10个按钮的AlertDialog如何在Android中向AlertDialog添加10个按钮?,android,android-alertdialog,Android,Android Alertdialog,我正在尝试创建一个包含10个按钮的AlertDialog 但是在AlertDialog中只有3个按钮。解决方案是创建一个包含10个按钮的视图,然后通过 new AlertDialog.Builder().setView( your10ButtonView )... 尝试使用CustomDialog创建自己的布局,并在自定义AlertDialog中使用该布局。 像这样, private Dialog mForgetPasswordDialog; mForgetPasswordDial
但是在AlertDialog中只有3个按钮。解决方案是创建一个包含10个按钮的视图,然后通过
new AlertDialog.Builder().setView( your10ButtonView )...
尝试使用CustomDialog创建自己的布局,并在自定义AlertDialog中使用该布局。 像这样,
private Dialog mForgetPasswordDialog;
mForgetPasswordDialog = new Dialog(Signin.this);
mForgetPasswordDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mForgetPasswordDialog.setContentView(R.layout.forget_password);
mForgetPasswordDialog.setCancelable(true);
TextView btnOk = (Button) mForgetPasswordDialog
.findViewById(R.id.btnOk);
// do your stug
mForgetPasswordDialog.show();
您应该转到并参考“创建自定义布局”部分为什么???这是最糟糕的主意!想想需要从10个按钮中选择一个按钮来按下的用户。我如何创建包含10个按钮的视图?使用10个
创建一个xml布局,并在代码中使用类似视图的内容将其放大。放大(这个,R.layout.my_buttons,null)
,然后将结果放入setView()
。