Good Day,
what i am trying to achieve is the following:
Create a infinate scrooling list i found the folowing on GITHUB which i see comes highly recomended by Stackoverflow users.
https://github.com/shontauro/android-pulltorefresh-and-loadmore
the background is as such:
i have a database of posts in my database (over 2000 active posts) i would like to display 20 posts in a listview with the following fields
Pid Name title
then when the user reaches the end of the list it should load further 20 posts.
i know i need to somehow use OnNotifyDataSetChanged(); but have really no idea on how to impliment it.
all the tutorials i have found use a simple array adapter and can only accept a single item :(
The list should also have an onclick listner that will retrieve the post and set it to a new activity.
i can retrieve the posts using JSON from my server but to append the already displayed list has got me stumped.
public class DownloadJSON extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
// Retrieve JSON Objects from the given URL address
jsonobject = JSONfunctions.getJSONfromURL("http://www.example.com/posts.php?last_id=");
try {
// Locate the array name in JSON
jsonarray = jsonobject.getJSONArray("posts");
for (int i = 0; i < jsonarray.length(); i++) {
jsonobject = jsonarray.getJSONObject(i);
// Retrive JSON Objects
pid = jsonobject.getString("pid");
name = jsonobject.getString("name");
title = jsonobject.getString("title");
}
} catch (JSONException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
}
if anybody could please point me in the right direction i would really apperieate it
Thanks
Kenny