ive spent the last day and a half studying listviews and still cant seem to figure out what i want to do. Im trying to build a mock feed for a mockup app, after doing some research im guessing to do this i need to build a custom listview but, before i can even worry about the custom listview i need to figure out how to get one into my layout. listview to my layout. ive built a listview that uses listactivity but, i dont want the entire screen to be taken up by the list.
heres my code as of now:
the main class: http://pastebin.com/ExY4VLVv
the xml:
http://pastebin.com/3CTy29fQ
ive looked a little into everything i could find开发者_开发技巧 from trying to fragments to the above. I am not picky about how this gets accomplished at all as long as i can have my layout + a feed below it on the same activity. If im going about constructing this all wrong im open to suggestions as long as my end goal is accomplished.
I think this will help you to an answer:
1) Include a linear layout [with orientation set to Vertical] in the layout where you want to show your mock feed. Say the linear layout is named, listParent.
2) Write another layout file - say list_row.xml which has a linear layout [with orientation set to horizontal] which represents the contents of the feed. It can be like you have a image view on the left and some content on the right. Basically, what ever your "feed" is made up of.
3) In your activity code, once you get the feed-data, run them through an iterator loop, and for each data row, inflate the list_row.xml layout file and add them to the listParent linearLayout.
NOTE: You would want to preferably place the listParent linear layout inside a scrollView so that you can see all the contents if they grouw out of the normal screen size!
精彩评论