Alert Dialog for picking mutliple items

  // setup the alert builder        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Choose from ");

// add a list        String[] pic = { "Capture Photo","Video Record","Audio Record","Pick from Gallery"};// "Camera",        builder.setItems(pic, new DialogInterface.OnClickListener() {
            @Override            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                    case 0:
                        Toast.makeText(MainActivity.this, "Capture Photo", Toast.LENGTH_SHORT).show();
                    case 1:
                        Toast.makeText(MainActivity.this, "Video Record", Toast.LENGTH_SHORT).show();
                    case 2:
                        Toast.makeText(MainActivity.this, "Audio Record", Toast.LENGTH_SHORT).show();
                    case 3:
                        Toast.makeText(MainActivity.this, "Pick from Gallery", Toast.LENGTH_SHORT).show();
                }
            }
        });

        // create and show the alert dialog        AlertDialog dialog = builder.create();
        dialog.show();

Comments