我的应用程序中有一个AlerDialog,主要问题是在像Nougat或更高版本的版本中它可以工作,但是在Marsmallow或lolipop中,AlertDialog给出了requestFeature() must be called before adding content
错误,但是我没有放置任何requestWindowFeature
我的代码:
public Dialog onCreateDialog(Bundle savedInstanceState) {
return createRadioListDialog();
}
public android.app.AlertDialog createRadioListDialog() {
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
final CharSequence[] items = new CharSequence[3];
items[0] = "Voy a asistir";
items[1] = "No voy a asistir";
items[2] = "Aún no lo sé";
builder.setTitle("Asistencia")
.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
asistenciaD = String.valueOf(1);
guardarMeta();
dialog.dismiss();
Objects.requireNonNull(getActivity()).getSupportFragmentManager().beginTransaction().replace(R.id.container, new Main_Fragment_Asistencia(), "MainFragment")
.commit();
}if (which == 1) {
asistenciaD = String.valueOf(2);
guardarMeta();
dialog.dismiss();
Objects.requireNonNull(getActivity()).getSupportFragmentManager().beginTransaction().replace(R.id.container, new Main_Fragment_Asistencia(), "MainFragment")
.commit();
}if (which == 2) {
asistenciaD = String.valueOf(0);
guardarMeta();
dialog.dismiss();
Objects.requireNonNull(getActivity()).getSupportFragmentManager().beginTransaction().replace(R.id.container, new Main_Fragment_Asistencia(), "MainFragment")
.commit();
}
}
});
return builder.create();
}
}
非常感谢您的回答