DialogFragment setMultiChoiceItems未显示

时间:2013-10-15 14:04:25

标签: android dialogfragment

我正在尝试显示具有多个选项的DialogFragment:

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;
    }
}
}

使用此代码,我的DialogFragment仅显示标题和消息。知道为什么吗?

1 个答案:

答案 0 :(得分:2)

似乎你不能setMessage()到具有多重项目的构建器。