Does anyone know of any examples to dynamically load Json data into a ListView, most examples I have seen just use a static array of some kind. I need to load say 10 rows of Json data, then at the bottom have a load more.. to get the next 10 etc etc. Examples using Json please....
相关问题
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Bottom Navigation View gets Shrink Down
Programmer Bruce is correct, there is no default way to do this. However, there is a very clean and simple way to get this accomplished. Here is the adapter I use to handle JSONArrays.
Android doesn't have a ready-made adapter to populate a
ListView
with a JSON array, like it does for populating aListView
with database records.I recommend getting comfortable with populating a Java data structure of your choice with the JSON data, and getting comfortable with working with
ListViews
, populating them from different collections, with different custom rows.Here's a simple example of populating a
List
from a JSON array, and then using theList
to populate aListView
.Try the below:
JSON Parser class:
Fragment class showing Listview:
Activity details class:
Hope this helps ;)
dbaugh has a good answer, but this post explains how to use it for the rest of us who don't know where to go from there.
I made a simple JSONAdapter like this:
and then when I need a specific instance of it, I have to override the getView method in the adapter with my concrete need:
and set data like this: