I have ArrayAdapterinside it AsyncTask, but I'm not sure how to call notifyDataSetChangedfromonPostExecute
Example:
public class ColorAdapter extends ArrayAdapter<Color> {
List<Color> colorList;
Context context;
....
public ColorAdapter(Context context, List<Color> list) {
this.context = context; this.colorList = list;
}
public View getView (final int position, final View view, final ViewGroup parent) {
.....
}
class DeleteColorTask extends AsyncTask <String, String, String> {
int colorId;
DeleteColorTask (int colorId) {this.colorId = colorId;}
protected String doInBackgroud (String ... args) {
colorList.remove(colorList.indexOf(...));
}
protected void onPostExecute(String s) {
}
}
}
I call this from my activity as follows:
adapter = new ColorAdapter(context, colorsList);
setListAdapter(adapter);
source
share