1

I have an android app with a button. When clicking the button I need on the screen a dialob box with multiple check boxes annd an ok button. How to do that? Do i need an xml layout for the list with checkboxes?

1. How to add to each element in the list dialog box a check box?

2. How to put in a string all the checked elements when the button OK is pressed.

this is my code so far:

 app_part.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {


                final String items[] = {"1","2","3","4"};

                AlertDialog.Builder ab=new AlertDialog.Builder(ConferenceClass.this);
                ab.setTitle("SIP CONTACTS");
                ab.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface d, int choice) {
                    // on OK button action
                    }
                    });
                ab.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface d, int choice) {
                    // on Cancel button action
                    }
                    });
                ab.setItems(items, new DialogInterface.OnClickListener() {


                public void onClick(DialogInterface d, int choice) {


                }
                });
                ab.show();
                 //open contact list and select persons


                }
        });

1 Answer 1

1

Yes u can just create the layout like you would normally do, when u design a activity layout. THe only different is that you have to set in your manifest that its a dialog.

android:theme="@android:style/Theme.Dialog"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.