开发者

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

开发者 https://www.devze.com 2023-04-12 21:52 出处:网络
I have created a custom adapter to display different images in the each list items from the drawable resource.

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 开发者_JAVA技巧i need to display the list in a alertdialog or any other instead of displaying in another layout.


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


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

精彩评论

暂无评论...
验证码 换一张
取 消