arnp
arnp

Reputation: 3208

Can i use custom list to appear in a alert dialog?

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.

Upvotes: 0

Views: 1133

Answers (2)

Nibha Jain
Nibha Jain

Reputation: 8161

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

Upvotes: 0

K-ballo
K-ballo

Reputation: 81379

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

Upvotes: 1

Related Questions