Basically i have been try to do the damn this for over 40 hours – read all threads about it and still no result!!! So I can’t update list adapter in list view while posting in onPostExecute adapter.notifyDataSetChanged();
ArrayAdapter<String> adapter;
private ProgressDialog dialog;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setListAdapter(adapter);
dialog = new ProgressDialog(
Table.this);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage("Загружаю. Подождите...");
AsyncTask<Void, Void, Void> loadingTask = new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
dialog.show();
}
@Override
protected Void doInBackground(Void... params) {
........ adapter = new ArrayAdapter<String>(Table.this, android.R.layout.simple_list_item_1,CreateStringArray
.getString(myData, null, null, null, null));
return null;
}
@Override
protected void onPostExecute(Void result) {
adapter.notifyDataSetChanged();
Table.this.
dialog.dismiss();
}
};
loadingTask.execute();
getListView().setOnItemClickListener(this);
}
So it shows me the spinner and successfully load and deletes it. After a while of debugging i noticed that it successfully changes data in the adapter. Still it dent display it. Am working with listvew
By instantiating a new Adapter in
doInBackGroundyou lose the reference to the adapter you set doingsetListAdapter(adapter);Therefore, the adapter you notify in OnPostExecute is not the one in your ListView.