AlertDialog does not show dividers on a list

前端 未结 2 979
庸人自扰
庸人自扰 2021-02-13 06:26

I have this class:

public class PageDetailInfoView extends FrameLayout {

//few constructors and methods

//method to show an AlertDialog with a list
private voi         


        
相关标签:
2条回答
  • 2021-02-13 06:51

    It is probably because you are running your app on Android 5.0+ which has Material design.

    To get the "old" look, just construct your dialog with the Holo style:

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

    Although this might seem weird for some users (especially on Lollipop and Marshmallow, so I recommend looking into using custom views for your dialog.

    0 讨论(0)
  • 2021-02-13 06:55

    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();
    
    0 讨论(0)
提交回复
热议问题