gpt4 book ai didi

android - AlertDialog 不在列表中显示分隔符

转载 作者:可可西里 更新时间:2023-11-01 18:50:58 25 4
gpt4 key购买 nike

我有这门课:

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

事实上,我明白了,但没有灰色分隔线。
知道为什么吗?

enter image description here

最佳答案

AlertDialog 列表项分隔线颜色更改为:

AlertDialog alertDialogObject = dialogBuilder.create();
ListView listView=alertDialogObject.getListView();
listView.setDivider(new ColorDrawable(Color.BLUE)); // set color
listView.setDividerHeight(2); // set height
alertDialogObject.show();

关于android - AlertDialog 不在列表中显示分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33500765/

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