AlertDialog不在列表上显示分隔线 [英] AlertDialog does not show dividers on a list
本文介绍了AlertDialog不在列表上显示分隔线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我上了这堂课:
public class PageDetailInfoView extends FrameLayout {
//few constructors and methods
//method to show an AlertDialog with a list
private void openDialog(){
List<String> mTags = new ArrayList<String>();
mTags.add("Item1");
mTags.add("Item2");
mTags.add("Item3");
mTags.add("Item4");
mTags.add("Item5");
mTags.add("Item6");
final CharSequence[] tags = mTags.toArray(new String[mTags.size()]);
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("Title");
builder.setItems(tags, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
//do something
}
});
Dialog alertDialogObject = builder.create();
alertDialogObject.show();
}
在调用openDialog()之后将打开警报"对话框,但事实是它没有显示项目之间的分隔线.
我想得到这个:
http://2.bp.blogspot.com/-i00d8VG6WsQ/UrGIeyb-8II/AAAAAAAAHwA/8MPWP5qrQ78/s500/alertdialog-with-simple-listview.png
The Alert dialog is opened after invoke openDialog() but the thing is that it does not exhibit the dividers between items.
I would like to get this:
http://2.bp.blogspot.com/-i00d8VG6WsQ/UrGIeyb-8II/AAAAAAAAHwA/8MPWP5qrQ78/s500/alertdialog-with-simple-listview.png
,实际上,我知道了,但没有灰色分隔线.
知道为什么吗?
and ,in fact, I get it but without the Gray dividers.
Any idea about why?
推荐答案
更改AlertDialog
列出项目分隔线颜色为:
Change AlertDialog
List items divider color as:
AlertDialog alertDialogObject = dialogBuilder.create();
ListView listView=alertDialogObject.getListView();
listView.setDivider(new ColorDrawable(Color.BLUE)); // set color
listView.setDividerHeight(2); // set height
alertDialogObject.show();
这篇关于AlertDialog不在列表上显示分隔线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文