Android Listview on rebuild not showing new items until scroll down -


OK, so I have a list view that populates JSON data from the web population. I wrap the item in a SwypeRefreshLayout. What is happening when I pull down, get data, clears Array's list, rebuilds it and then informs the data set change adapter However, Im not seeing new data yet New on top To see the objects, I need to look down and back up behind it.

Here the code I am using is using the list to refresh.

  swipelists.setOnRefreshListener (New SwipeRefreshLayout.OnRefreshListener () {@Override public void onRefresh () {if (getArguments () getInt (ARG_SECTION_NUMBER) == 3.) {recentArrayList.clear (); long totalSize = 0; recadapter = new ArrayAdapter (ctx, android.R.layout.simple_list_item_1, recentArrayList) ;. new updatetheRecent (execute) (Ctx);} and {swipelists.setRefreshing (false);}}});  

The function that list is being called for Reconstruction

  private class updatetheRecent extends AsyncTask & LT; Context, integer, long & gt; {Secure long doInBackground (reference ... URL) {int count = urls.length; Long-sized size = 0; {HttpClient httpclient = Try New DefaultHttpClient (); // Create HTTP Client HTTP GET httpget = New HTTP Gate ("http://test.net/pltxtrec.php"); HttpResponse response = httpclient.execute (httpget); // Executeit HttpEntity unit = response.getEntity (); InputStream = entity.getContent (); // Create an InputStream with Response BufferedReader Reader = New BufferedReader (New InputStreamReader ("iso-8859-1"), 8); Stringbilder sb = new stringbiller (); String line = null; While reading the line by line sb.append (line + "\ n") ((line = reader. Readline ()) = null; String reststrings = sb.toString (); // result is here JSONArray json = new JSONArray (resString); (Int i = 0; i & lt; json.length (); i ++) for {JSONObject json_data = json.getJSONObject (i); String jsonvalues ​​= json_data.getString ("title"); If "{recentArrayList.add (json_data.getString (() Artist") + "-" + json_data.getString ( "title")) jsonvalues.equals ( "!)"; // .. All values ​​here}} if (recently Araylitkaisaple ()) (Haliaarerelistkaed ( "current queue any item");} close (in); // Section GetActivity () Close RunOnUiThread (new Runnable () {public void run () {RecadapterknotifyDataSetChanged (); SwipelistsksetRefreshing (false);}}).} catch (exception e) {} return total;} void OnProgressUpdate (int ... Progress) {} Protected Zero onPostExecute (Long result) protected {if (recentlist = null!) {// this is add, but its recentlist.smoothScrollToPosition being called Never tried (0);}}}}  

Your HTTP The request is an async function, which means that it will return when it returns, you can not drag the content of such content that has not yet arrived.

I have tested it, but such a It sounds like what you want is a refreshing () method from Swipe Refresh Layouts.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -