AndroidRuntimeException:AlertDialog

时间:2018-03-22 14:50:53

标签: android-alertdialog

我的应用程序抛出异常 - 在AlertDialog中添加内容之前必须调用“android.util.AndroidRuntimeException:requestFeature()。

alertdialogbuilder = new AlertDialog.Builder(this);
List<String> itemsIntoList = Arrays.asList(AlertDialogItems);
alertdialogbuilder.setMultiChoiceItems(AlertDialogItems, Selectedtruefalseenter code here, (dialog, which, isChecked) -> {});
alertdialogbuilder.setCancelable(false);

alertdialogbuilder.setPositiveButton("אישור", (dialog1, which) -> {
mMailNotification.setChecked(Selectedtruefalse[0]);
mMailAgree.setChecked(Selectedtruefalse[1]);
dialog1.dismiss();
});

AlertDialog dialog1 = alertdialogbuilder.create();

dialog1.getWindow().getAttributes().windowAnimations = R.style.DialogTheme;
dialog1.getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);

dialog1.show();

ListView listView = dialog1.getListView();
listView.setDivider(new ColorDrawable(Color.LTGRAY));
listView.setDividerHeight(2);

我认为“带RTL的setLayoutDirection”是麻烦制造者,但不确定 - 它必须是rtl。

此致 YUR

1 个答案:

答案 0 :(得分:0)

  AlertDialog.Builder builder = new AlertDialog.Builder(context);
  View view = new View(context);
  view.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
  builder.setView(view);
  builder.create();