警报对话框选项之间的分隔线

Divider between the options of alert dailog

我正在使用警告对话框来显示 whatsapp 中的操作。

AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);

我正在使用 setItems() 方法提供选项列表

dialog.setItems(options.toArray(new String[options.size()]), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(mContext, AddTaskActivity.class);
                mContext.startActivity(intent);
            }
        });

但问题是它还在像这样显示不同选项之间的分隔符, 截屏:

现在的问题是我想隐藏分隔符。任何帮助表示赞赏。 提前致谢:)

因此,根据此 post Alertdialog default button divider removal,问题出现了,因为您的项目在 ListView 中膨胀,布局 simple_list_item - 其底部是分隔线。解决方案是将分隔线高度设置为 0:

AlertDialog alertDialog = builder.create();
alertDialog.getListView().setDividerHeight(0);

编辑:在 API 21 上测试 - 即使没有添加也没有行。