开发者

How to Create ONE list which can have a string or image as an item in the list

开发者 https://www.devze.com 2023-03-16 01:16 出处:网络
I want to create a journal that appears as a list in a ListView. The list should be able to have a text entry or an image for each row. Now, I have these entries (text and image) in a database. I just

I want to create a journal that appears as a list in a ListView. The list should be able to have a text entry or an image for each row. Now, I have these entries (text and image) in a database. I just want to know how to create a list adapter which can have these entries. 开发者_StackOverflowFrom the examples I have seen, the list adapters all have only one data type. I want my adapter to have data type image or text. Please Help! Been searching for 3 hours now.


To show images in some listItems and text in others, declare both an ImageView and a TextView in the listitem xml, and hide/show one of them with View.setVisibility(...), where you bind the content. For examples of multiple children in a listItem, refer to other Nik's answer

0

精彩评论

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