How can inflate a layout containing listview in a alert dialog? How can inflate a layout containing listview in a alert dialog? android android

How can inflate a layout containing listview in a alert dialog?


All you are doing is inflating a view into your alert dialog. You aren't setting the adapter on that listview so of course it's going to appear to not be working (since its empty).

You need to do something like:

View view = getLayoutInflater().inflate( R.layout.smill, null);ListView listView = (ListView) view.findViewById(R.id.listView);YourCustomAdapter adapter = new YourCustomAdapter(parameters...);listView.setAdapter(adapter);AlertDialog.Builder dialog = new AlertDialog.Builder( this );dialog.setView(view);.........dialog.show();