gpt4 book ai didi

android - DialogFragment setMultiChoiceItems 不显示

转载 作者:行者123 更新时间:2023-11-29 21:31:27 24 4
gpt4 key购买 nike

我正在尝试显示具有多个选择的 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 仅显示标题和消息。知道为什么吗?

最佳答案

似乎您不能 setMessage() 到具有多项选择项的构建器。

关于android - DialogFragment setMultiChoiceItems 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19383286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com