I am calling a webservice
through asynctask
, to call the webservice
i am calling one method named makeRequest()
in
call the success method on onPostExecute method
Since this the error that comes up when you do some MainThread task in another thread.....
try This:
runOnUiThread(new Runnable(){
public void run(){
this.adapter.setList(list);
this.adapter.notifyDataSetChanged();
}
});
This code might have some errors But in simple Words.. add the notifyDataSetChanged call into runOnUiThread() method. You will be Done..
OR this can also be DOne ( the perfect way )
add the following in your activity class
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
this.adapter.setList(list);
adapter.setnotifyDataSetChanged();
}
};
Call this handler when and where you want to call the notifydatasetchanged like this
handler.sendEmptyMessage(0);
Thanks sHaH
You should update your List like this.
Activity_name.this.runOnUiThread(new Runnable() {
@Override
public void run() {
list = (ArrayList<Map<String, String>>) result;
this.adapter.setList(list);
this.adapter.notifyDataSetChanged();
}
});