My android application starts an activity which contains list view. Activity also contains one Button while pressing on it, it runs on asynctask and produce some result which should be updated(add one more item) to the list view. In my case the issue is asynctask produce the result but i don't no how to update my list view. Also i don't want to use loading symbol.
Asked
Active
Viewed 46 times
0
-
are you getting response in post execute of asynctask – Vivek Mishra Feb 19 '16 at 17:51
-
Yes,Post execute returns result. – kalai Feb 19 '16 at 17:53
-
then also add your code for better understanding – Vivek Mishra Feb 19 '16 at 17:53
3 Answers
0
In the onPostExecute() of your AsyncTask you should add the new item to the List or ArrayList of your desired data and then call the listAdapter.notifyDatasetChanged() which will update the content of your listview.

Farhad
- 12,178
- 5
- 32
- 60
-
if my asynctask is in separate class, how can I get notified by the post execute method to ui. – kalai Feb 19 '16 at 18:21
-
0
Update your array list in onpostexecute() method. And then call notifydatasetchange method to update list.
For how to add check this- https://stackoverflow.com/a/19468504/2128166

Community
- 1
- 1

Wasim K. Memon
- 5,979
- 4
- 40
- 55
0
It is very simple. When doInBackground() method return something, you have to override onPostExecuteMethod(). Inside this method you are on MainThread, so you can call for example:
protected void onPostExecute(List<String> result) {
list.clear();
list.addAll(result);
adapter.notifyDataSetChaned();
}

user3528466
- 186
- 2
- 17