开发者

Set icon for multichoiceitem

I hava an alerDialog which enables the user to select multiple items.(set using the multichoiceitems() method).I want to add an icon for each of these items.Is this 开发者_如何学Gopossible.

I want a separate icon to be displayed for each of the selectable items.I have the icons stored in a drawable array.Any help would be appreciated.


If you need custom item renderers for your multichoice list, - instead of using the AlertDialog.Builder class - you should create your custom ListView with checkbox, icon and text, and put it in a dialog, then pop it up:

final Dialog dialog = new Dialog(this);
dialog.setContentView(new MyListView());
dialog.show();

where

class MyListView extends ListView ...

is your implementation of the ListView. In it's adapter you can inflate a simple RelativeLayout with the three fields you need, fill it with the proper data, set checklisteners, and you'll have your multichoice list with icons, ready to be set as a Dialog's contentView.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜