我正在尝试显示具有多个选项的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仅显示标题和消息。知道为什么吗?
答案 0 :(得分:2)
似乎你不能setMessage()
到具有多重项目的构建器。