0

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.

Farhad
  • 12,178
  • 5
  • 32
  • 60
kalai
  • 839
  • 1
  • 7
  • 5

3 Answers3

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
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