1

I'm trying to show a DialogFragment with multiple choices:

package ro.todo;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.Toast;

public class DialogSettings extends DialogFragment {
    boolean[] checkedItems={false,false,false};
    final String[] items={"Low priority", "Medium priority", "High priority"};
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        getCheckedItems();
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle("App settings").setMessage("Show activities in notification bar:")
                .setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which, boolean isChecked) {

                    }
            });
    return builder.create();
}
private void getCheckedItems(){
    if(System.showNotificationsLow){
        checkedItems[0]=true;
    }
    if(System.showNotificationsMedium){
        checkedItems[1]=true;
    }
    if(System.showNotificationsHigh){
        checkedItems[2]=true;
    }
}
}

With this code, my DialogFragment only shows only the title and the message. Any idea why?

4

1 回答 1

2

setMessage()对于拥有多项选择项的构建器来说,您似乎无法做到这一点。

于 2013-10-15T16:17:47.933 回答