I have a butoon, on clicking of this button i want to open multiple buttons on a single AlertDialog like this :
Give Me a help :
I was using this.... to add multiple buttons
alertDialog.setButton(delete, "Delete", new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub } });
but I found..., change setButton() to setButton2().. something like..... wt xcan i do for this....
There should not be more than three action buttons in AlertDialog, and they are positive, negative, and neutral. Positive is used to accept and continue with the action.
A simple dialog containing an DatePicker . This class was deprecated in API level 26.
AlertDialog. A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout.
Step 1: Create a XML file: custom_layout. Add the below code in custom_layout. xml. This code defines the alertdialog box dimensions and add a edittext in it.
A simple solution without xml:
AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Title"); builder.setItems(new CharSequence[] {"button 1", "button 2", "button 3", "button 4"}, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // The 'which' argument contains the index position // of the selected item switch (which) { case 0: Toast.makeText(context, "clicked 1", Toast.LENGTH_SHORT).show(); break; case 1: Toast.makeText(context, "clicked 2", Toast.LENGTH_SHORT).show(); break; case 2: Toast.makeText(context, "clicked 3", Toast.LENGTH_SHORT).show(); break; case 3: Toast.makeText(context, "clicked 4", Toast.LENGTH_SHORT).show(); break; } } }); builder.create().show();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With