Async And Listview Android
BackgorundTask.java (How to get the result of OnPostExecute() to main activity because AsyncTask is a separate class?) public class BackgroundTask extends AsyncTask
Solution 1:
your code is fine. you just need to call this line after adding data
listAdapter.add(output); // after this line add below line
listAdapter.notifyDataSetChanged();
Solution 2:
The code to get the data back to the activity and to your listadapter seems okay to me. I think you just need to add a listAdapter.notifyDataSetChanged();
after listAdapter.add(output);
so the listview knows it has to render itself anew.
Solution 3:
You have to set the adapter again when you receive output string as below :
BackgorundTaskasyncTask= (BackgorundTask) newBackgorundTask(newBackgorundTask.AsyncResponse(){
@OverridepublicvoidprocessFinish(String output){
listAdapter.add(output);
adapter = newMyCustomAdapter(listAdapter, this);
finalListViewmainListView= (ListView)findViewById(R.id.listView);
mainListView.setAdapter(adapter);
}
}).execute("some url");
Post a Comment for "Async And Listview Android"