I'm working on one of my first Android apps in which I load some JSON from the web and, after parsing, display the data in a ListView
. When the app first launches, the ListView
is empty. After the data is loaded, it's quite full. However, even while using notifyDataSetChanged()
on my adapter, the ListView
doesn't refresh and show the newly-loaded data until I press a key on the simulator's keyboard.
This is the processing I perform. I download the JSON, parse it, then my code looks like this - now, nothing shows at all, not even when pressing a key:
JSONArray jObject = new JSONArray(new2);
int l = jObject.length();
downloadedArrayOfStrings = new String[jObject.length()];
for(int i = 0; i < l; i++){
Log.v("i", ""+i);
jObject.getJSONObject(i).getString("category").toString();
}
ArrayList<String> lst = new ArrayList<String>();
lst.addAll(Arrays.asList(downloadedArrayOfStrings));
newAdapter = new MobileArrayAdapter(this, lst, downloadedArrayOfStrings);
newAdapter.setJSONArray(jObject);
setListAdapter(newAdapter);
Any ideas as to why this is happening, and how to fix it?