Android AlertDialog不会在列表上显示分隔符

Android AlertDialog不会在列表上显示分隔符,android,android-alertdialog,Android,Android 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")

我有这门课:

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();


}
public类PageDetailInfoView扩展了FrameLayout{
//很少有构造函数和方法
//方法显示带有列表的AlertDialog
私有void openDialog(){
List mtag=new ArrayList();
mTags.添加(“第1项”);
mTags.添加(“第2项”);
mTags.添加(“第3项”);
mTags.添加(“第4项”);
mTags.添加(“第5项”);
mTags.添加(“第6项”);
final CharSequence[]tags=mTags.toArray(新字符串[mTags.size()]);
AlertDialog.Builder=新建AlertDialog.Builder(getContext());
建造商名称(“名称”);
setItems(标记,新的DialogInterface.OnClickListener(){
公共void onClick(对话框接口对话框,int项){
//做点什么
}
});
Dialog alertDialogObject=builder.create();
alertDialogObject.show();
}
调用openDialog()后会打开警报对话框,但问题是它不会显示项目之间的分隔符。 我想得到这个:

事实上,我知道了,但没有灰色的分隔符。
知道为什么吗


更改
警报对话框
将项目分隔器颜色列为:

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

这可能是因为你正在安卓5.0+上运行你的应用程序,安卓5.0+具有材质设计

要获得“旧”外观,只需使用Holo样式构建对话框:

ContextThemeWrapper themedContext = new ContextThemeWrapper(getContext(), android.R.style.Theme_Holo_Light_Dialog_NoActionBar);
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
// ... then create your dialog

尽管这对某些用户来说可能有些奇怪(尤其是在棒棒糖和棉花糖上),所以我建议您在对话框中使用自定义视图。

谢谢Daniel,观点很好,但不起作用,仍然没有分隔符:(您可以添加一个关于当前进度的屏幕截图吗?关于添加的屏幕截图您在课程顶部的导入语句是什么?导入android.app.Activity;导入android.app.Dialog;导入android.content.Context;导入android.content.DialogInterface;导入android.content.res.Resources;导入android.graphics.Bitmap;导入androi)d、 support.v7.app.AlertDialog;导入android.support.v7.internal.view.ContextThemeWrapper;导入android.util.AttributeSet;导入android.view.LayoutFlater;导入android.view.view;导入android.widget.FrameLayout;导入android.widget.LinearLayout;导入android.widget.TextView;导入android.widget.Toast、 谢谢,但我无法访问.getListView(),这是有效的!但是您必须将
Dialog alertDialogObject=dialogBuilder.create();
更改为
AlertDialog alertDialogObject=dialogBuilder.create();
这是有效的,但列表末尾也添加了一行。