String[] items = {"Option 1", "Option 2", "Option 3"}; boolean[] checkedItems = {false, true, false}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select options"); builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { // Handle click event } }); AlertDialog dialog = builder.create(); dialog.show();
import androidx.appcompat.app.AlertDialog; String[] items = {"Option 1", "Option 2", "Option 3"}; boolean[] checkedItems = {false, false, false}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select options"); builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { // Handle click event } }); AlertDialog dialog = builder.create(); dialog.show();This example is similar to the previous one, but it uses the androidx.appcompat package instead of the android.app package.