Question

I have created a custom adapter to display different images in the each list items from the drawable resource. Now the custom adapter is working good in a listview. Now i need to display the list in a alertdialog or any other instead of displaying in another layout.

Was it helpful?

Solution

Display it on a regular subactivity that looks like a dialog instead.

OTHER TIPS

This code snippet shows a custom list inside a dialog box... :

        Dialog dialog2 = new Dialog(Activity.this);
        ListView modeList = new ListView(Activity.this);
        AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this);


            builder.setTitle(" results[s] ");
            MySimpleAdapter adapter = new MySimpleAdapter(Activity.this, data , R.layout.list_main, 
                    new String[] { "name", "distance" ,"phone","web"}, 
                    new int[] { R.id.item_title, R.id.item_subtitle ,R.id.item_subtitle1 ,R.id.item_subtitle2});
            modeList.setAdapter(adapter);
        }





        builder.setView(modeList);
        dialog2 = builder.create();
        dialog2.show();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top