I am currently making an android application which need to present a lot of information from different arrays. On each horizontal line there's gonna be four different texts and then I need to be able to scroll through all information displayed. I know ListView is one way to go, problem is I dont know how to use four text views horizontally in a ListView. Any tips or help to get the best way to present the information would be grealy appreciated.
Basically like this:
You have to extend ArrayAdapter and override getView() of Array Adapter.
Related
How can I display information in the following format? What controls should I use, listView or RecycleView?
Note that the question isn't about this particular activity and how to use it. It's about how to show the information in the same format and how to create the layout for it.
That is a ListView. You would just need a ListAdapter/ArrayAdapter to fill it and that's about it.
You can make exactly the same thing using the layout simple_expandable_list_item_2 in the SimpleAdapter of a ListAdapter (here is how you do it : Displaying kind of static data in ListView)
RecyclerView is of course much better in terms of performance and flexibility. However, ListView is enough in many cases like this one.
So I did some research and testing of using a listview in a scrollview, and as a lot of people may know this is supposedly bad to do, since they both scroll. It also means I can't show the complete listview as it will wrap to be smaller.
I have seen places which re change the height of the listview to fix this problem but again most people say that it isn't preferred.
What I would like to know though is what is the preferred way of making a nonscrollable listview like view? Basically I want the exact same as the listview but obviously non scrolled and the height based on its contents. I would prefer to work with the layout in as much XML as possible, and I would like to be able to send my array list to it to view on screen. Unfortunately either my search skills are quite dull, as I haven't been able to find anywhere that really explains the preferred method so I thought I would ask here.
Thanks for your help.
<>Clarification Information
I thought I would put this here in case it will help, first off I basically want to show an image, with a list of comments (each one has an author and a text) below it, the comments themselves are obtained from an array and can change. I want the whole page to be scrollable though so I can either view more comments or go back up to the image.
Using a RecyclerView and an adapter supporting multiple item types you could make a list which shows an image on top and several comments below it. Generally you'd have to check what item corresponds to each position - in your case on position 0 you have an image and in every other position you'd have a comment. Then in your adapter's onCreateViewHolder and onBindViewHolder you would check the item type and handle them differently.
You could take a look at this answer for a short example.
Let me know if you'd need any other details and/ or sample codes to get the idea. :)
What I want to have is a listview populated with my custom Folder class at the top, and objects at the bottom. I was thinking it would look something like it does in an OS.
I've spent hours looking through tutorials online, but the best I could find was putting an image and some text in the same row.
To be clear, I'm looking for something like this:
Folder_1
Folder_2
Folder_3
Item_1
Item_2
all in the same list.
Could anyone here help me figure this out?
The appearance of list items in a ListView is controlled by the getView() method of the list's Adapter. Any kind of customization that you want to do on a per-item basis (which includes having totally different list items) can be done from the getView() method. If you share some of the code of what you have already tried, others can help you further.
I'm building a contacts app and wanted to know what the best way of building something like the image below(Jessica is not too shabby...) in terms of using a list view, scrollview, etc.
Ideally, all of my data is in the sql database so a cursor adapter wouldn't be an issue. Is it better to have a listview with separators, or a scrollview where you add views. Since all contacts won't have exactly the same information, what can we do to make that? Any ideas would be greatly appreciated.
If you plan to have interactive elements inside of the items (e.g. the message button in the screenshot above) I'd recommend a ScrollView. Actually, since you probably don't have that many items I would again recommend a ScrollView. Then it's justa matter of having a set of layouts that you dynamically add depending on the information you have for the contact.
i am quite new to android and i was wondering how i could go about adding a listview with different images and text. What i am trying to achieve is a listview with four rows which have a different Icon? I don't know how to set that up using the xml layout provided. should i build this using different multiple linear layout or is there a better way to go about it?.. All the examples i have seen all seem to be using one particular Icon and no much detail of the xml layout. Any help will be greatly appreciated. Thank you
If you have a fixed number of rows you can just use a LinearLayout and save yourself some headache. If you need to have a dynamic number of rows then you need to make a custom adapter for your list. If you do a Google search, there are a lot of tutorials on how to do that.