package fshizzle.com;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
imp
For more infos here my code use for dynamicaly load listview ;)
this.getListView().setOnScrollListener(new OnScrollListener(){
//useless here, skip!
public void onScrollStateChanged(AbsListView view, int scrollState) {}
//dumdumdum
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
//what is the bottom iten that is visible
int lastInScreen = firstVisibleItem + visibleItemCount;
//is the bottom item visible & not loading more already ? Load more !
if((lastInScreen == totalItemCount) && (loadingMore)){
Adapter.notifyDataSetChanged();
}
if((lastInScreen == totalItemCount) && !(loadingMore)){
i++;
//on envoie la page a aller chercher
String page3 = getPage(var_global.URL+"listview.php?login="+login+"&page="+i);
Log.i(LOG_TAG, page3);
JSONObject json = JSONfunctions.getJSONfromURL(var_global.URL+"json/listview/"+login+".json");
try{
JSONArray earthquakes = json.getJSONArray("infos");
for(int i=0;i map = new HashMap();
JSONObject e = earthquakes.getJSONObject(i);
//si user == a endlist
if (e.getString("user").equals("endlistfshizzle")) {
loadingMore = true;
}
map.put("id", String.valueOf(i));
map.put("name", "infos name:" + e.getString("user"));
map.put("age", "age: " + e.getString("age"));
URL pictureURL = new URL(var_global.URL+"upload/thumbs/"+e.getString("image"));
Bitmap bitmap = BitmapFactory.decodeStream(pictureURL.openStream());
map.put("img",bitmap);
//http://www.imagemagick.org/Usage/thumbnails/
mylist.add(map);
}
}catch(JSONException e) {
Log.e("log_tag", "Error parsing data "+e.toString());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Adapter.notifyDataSetChanged();
}
}
});
Good programming at all !!