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();
精彩评论