MorZa
MorZa

Reputation: 2325

Alert dialog items are not at the same height

I have an alert dialog that its items are all in the same height besides the last one that is higher, and I have no idea why. I tried to set it with:

textView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, 80 )); 

but it didn't help, the last one is still higher... any ideas?

enter image description here

This is my Layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >    
</LinearLayout>

and this is the code in the Activity:

            final CharSequence[] items;
            List<String> listItems;

                listItems = new ArrayList<String>();

                listItems.add("Remind me in a week");
                listItems.add("Set a reminder");
                listItems.add("Save permanently");
                listItems.add("Delete now");
                items = listItems.toArray(new CharSequence[listItems.size()]);

final View view = getLayoutInflater().inflate(R.layout.custom_alert, null);
        AlertDialog.Builder alert = new AlertDialog.Builder(this)
        .setTitle("When do you want to delete " + name + "?" )
        .setView(view)
        .setCancelable(true)
        .setSingleChoiceItems(items, 4, new DialogInterface.OnClickListener()

Upvotes: 0

Views: 95

Answers (1)

Konrad Krakowiak
Konrad Krakowiak

Reputation: 12365

You should remove setView(view) method. It is not necessary. You just put empty LinearLayout which is redundant on this dialog.

Upvotes: 1

Related Questions