Sunday, November 25, 2018

Android: How to show dialog with choice items

String[] linkedNames = {"One","Two","Three"};
        AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
        //alt_bld.setIcon(R.drawable.icon);
        alt_bld.setTitle("Select one");
        alt_bld.setSingleChoiceItems(linkedNames, 0, new DialogInterface.OnClickListener(){
            public void onClick(DialogInterface dialog, int item) {
                Log.v(LOG_TAG,"Selected one")
                dialog.dismiss();// dismiss the alertbox after chose option
            }
        });
        AlertDialog alert = alt_bld.create();
        alert.show();

No comments:

Post a Comment