Unable to get custom list view in alert dialog
<p>I am implementing custom list view in alert dialog. It's not showing up any view.</p>

<p>I have created one query to get the list of titles from table. I want to show this list in alert dialog.</p>

<p>What's going wrong?</p>

<p>alert dialog :</p>

<pre><code>   selectTable.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                int selected = 0;

                TimeTableHelper th = new TimeTableHelper(getApplicationContext());
                final List&lt;String&gt; tables = new ArrayList&lt;String&gt;(th.getTitle());


            AlertDialog.Builder alertDialog = new AlertDialog.Builder(AddEventActivity.this);
            LayoutInflater inflater = getLayoutInflater();
            View convertView = (View) inflater.inflate(R.layout.tablelist, null ,false);
            alertDialog.setView(convertView);
            ListView lv = (ListView) convertView.findViewById(R.id.list);

            CustomAlertAdapter adapter = new CustomAlertAdapter(AddEventActivity.this, (ArrayList&lt;String&gt;)tables);
            lv.setAdapter(adapter);


                alertDialog.setSingleChoiceItems(adapter,selected,
                        new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int item) {

                                ListView lw = ((AlertDialog)dialog).getListView();
                                Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());

                                txtTable.setText(String.valueOf(checkedItem));
                                dialog.dismiss();
                            }
                        });
                alertDialog.show();

            }
        });
</code></pre>

<p>customAlertAdapter</p>

<pre><code>public class CustomAlertAdapter extends BaseAdapter{

    Context ctx=null;
    ArrayList&lt;String&gt; listarray=null;
    private LayoutInflater mInflater=null;
    public CustomAlertAdapter(Activity activty,ArrayList&lt;String&gt; list)
    {
        this.ctx=activty;
        mInflater = activty.getLayoutInflater();
        this.listarray=list;
    }
    @Override
    public int getCount() {

        return listarray.size();
    }

    @Override
    public Object getItem(int arg0) {
        return null;
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
        final ViewHolder holder;
        if (convertView == null ) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.alertlistrow, null);
            holder.titlename = (TextView) convertView.findViewById(R.id.tableTitle);
            convertView.setTag(holder);
        }
        else {
            holder = (ViewHolder) convertView.getTag();
        }

        String datavalue=listarray.get(position);
        holder.titlename.setText(datavalue);

        return convertView;
    }

    private static class ViewHolder {
        TextView titlename;
    }
</code></pre>

<p>alertlistrow layout :</p>

<pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1"
    android:orientation="vertical"
    android:measureWithLargestChild="false"&gt;


        &lt;RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"&gt;
            &lt;Button
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center|right"
                android:background="@drawable/circle_shape"
                android:id="@+id/selectColor"
                android:layout_alignTop="@+id/switch2"
                android:layout_alignParentStart="true"
                android:layout_marginLeft="20dp" /&gt;
            &lt;TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="@android:style/TextAppearance.Medium"
                android:id="@+id/tableTitle"
                android:layout_alignParentLeft="false"
                android:layout_alignParentStart="false"
                android:layout_centerVertical="true"
                android:layout_toRightOf="@+id/selectColor"
                android:layout_marginLeft="10dp" /&gt;


        &lt;/RelativeLayout&gt;


&lt;/LinearLayout&gt;
</code></pre>