建立多重選單必須使用AlertDialog.Builder 來達成, 如下

package com.example.layout;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.os.Bundle;
import android.util.Log;
public class MultiChoiceItemsActivity extends Activity
{
    protected static final String TAG = "MultiChoiceItemsActivity";
    private String[] mItems = new String[] {
            "item1", "item2", "item3", "item4", "item5"
    };
    private boolean[] mCheckItems = new boolean[mItems.length];
    private void showAlertDialog()
    {
        Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Title");
        builder.setMultiChoiceItems(mItems, mCheckItems, new OnMultiChoiceClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which, boolean isChecked)
            {
                if (isChecked) {
                    mCheckItems[which] = true;
                }
            }
        });
        builder.setNegativeButton("Negative", new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                String checkItemsResult = "";
                int checkItemslength = mCheckItems.length;
                for (int i = 0; i < checkItemslength; ++i) {
                    if (mCheckItems[i]) {
                        checkItemsResult = checkItemsResult + mItems[i];
                    }
                }
                Log.d(TAG, checkItemsResult);
            }
        });
        builder.show();
    }
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_multi_choice_items);
        showAlertDialog();
    }
}

 
第17行為多重選項的內容
第21行為紀錄哪些選項被選擇
第27行設定多重選項並傳入顯示的選項內容
第32行藉由isChecked判斷哪些選項被勾選,並紀錄在mCheckItems中
第38行加入Button
第43~50行為顯示被勾選的選項