【发布时间】:2019-04-08 08:44:07
【问题描述】:
我有四个项目(字符串数组)的警报对话框,我想在每个项目之间添加分隔线和不同颜色的第一个分隔线,我在 android 4.4 kitkat 上看到了这样的
这是我的警报对话框代码
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(getString(R.string.choose_layout));
String[] recyclerViewLayouts = getResources().getStringArray(R.array.RecyclerViewLayouts);
SharedPreferences.Editor editor = sharedPreferences.edit();
dialog.setItems(recyclerViewLayouts, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int index) {
}
}
});
dialog.create();
dialog.show();
我尝试使用以下代码创建它,但也没有显示
AlertDialog alertDialog = builder.create();
ListView listView = alertDialog.getListView();
listView.setDivider(new ColorDrawable(Color.GRAY));
listView.setDividerHeight(1);
alertDialog.show();
【问题讨论】:
标签: android android-layout android-alertdialog android-theme android-styles