Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Divider between the options of alert dailog

I am using alert dialog to show actions as in whatsapp.

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

And i am supplying the list of options using setItems() method

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

But problem is that it is also showing separator between different options like this, Screenshot: enter image description here

Now the problem is that I want to hide the separators. Any help is appreciated. Thanks in advance :)

like image 830
Awadesh Avatar asked Dec 29 '25 01:12

Awadesh


1 Answers

So, according to this post Alertdialog default button divider removal, the problem occurs, because your items are inflated in a ListView, with the layout simple_list_item - whose bottom is a divider. Solution was to set the divider height to 0:

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

Edit: tested on API 21 - no lines even without the addition.

like image 75
yennsarah Avatar answered Dec 31 '25 13:12

yennsarah