I would like a listview that is populated by json and which look similar to the images.
I have used a normal listview from android before but i dont like the look and feel of it.
My question.
How did they create these listviews? Are they even listviews or did they use something else?
I just want a nice scrollable list for my json content.
Any ideas or suggestions would be appreciated.
Links to tutorials would also be great.
Kind regards
Of course listview could do that. You many define a layout xml for cell, then in the adapter's getView method, inflate cell view from the layout xml, then configure elements in the cell according to your data.
Related
My problem is simple: I need to make a layout similar to android.R.layout.simple_expandable_list_item_1 which can fit more than one textview in the layout, as well as show the little '>' symbol that indicates that the tab is expandable.
How can this best be accomplished? My first thought was to use the layout as a background of a linear layout with two textviews in it, but I can't seem to make that work.
Vogella has a pretty good tutorial on how to achieve custom list views through Adapters.
Basically, what you do is you create a Layout with the looks you want for the list items and then you extend an adapter (ArrayAdapter for instance), see section 4. Then, in your activity, you create an instance of your Adapter implementation and populate it from an Array containing the data for the list.
Also have a look at the Developers site for how to make the list scroll smoothly with the ViewHolder pattern.
And if you feel you need more info on the expandable part maybe the hive can help.
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.
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 have to implement a ListView or GridView where every item will have non-uniform height/width. Also a particular item could span multiple columns. A GridView is perhaps a better candidate, but again each row has a different schematic. The attached image best describes what I want to achieve.
I am looking for ideas on how best to implement this. I am not looking for code samples, but just some guidelines.
Right now, I'm thinking of implementing a custom ListAdapter where each row is laid out in the scheme I want. Of course then I'd have to do some tricks to map list indexes to actually items in array of items (if I use and array adapter). For example, in the mockup below, the penguins will have an index of 1 in my array, but 0 in the ListView.
in these kind of structure you should use a layout in xml and add dynamic view in that layout from java file.
May be a relative Layout with ImageViews is good. It may get a bit messy for the .xml though! This seems quite interesting. Do keep us updated on which of the solutions you finally chose.
Thanks!
Does anyone have a good tutorial for implementing onItemClick() for a ListView populated by a custom ArrayAdapter?
I'm struggling with how Android is recycling views, and how to affect the layout of the selected view (which is a RelativeLayout). The way I've implemented it, I'm just doing a simple background colour change, but everytime I choose a row, when I scroll the ListView there are other off screen items selected too.
Any ideas?
Have a look to this answer. Custom code of ArrayAdapter.getView() (where view recycling is done) might be useful to you, I was trying to achieve something similar and it worked for me at last :)
You can find lots of good examples of the custom Listview with Adapters.Some of the Examples are listed below:
(1)custom-listview-android
(2)android-custom-listview-with-image-and-text
(3)Custom Array Adapter