I've got a ListView
in on my activities. Upon clicking a button, an AynscTask
is invoked, which when completed attaches a BaseAdapter
to that ListView
in it's onPostExcecuteMethod
to show the results:
protected void onPostExecute(ArrayList<Result> objResults) {
ListView lvwResults = (ListView) objContext.findViewById(R.id.results);
lvwResults.setAdapter(new SearchResultsAdapter(this.objContext, objResults));
}
The adapter looks like this on a very simplified note:
public class SearchResultsAdapter extends BaseAdapter {
private static ArrayList<Result> objResults;
private Search ctxContext = null;
public SearchResultsAdapter(Search ctxContext, ArrayList<Result> objResults) {
this.ctxContext = ctxContext;
SearchResultsAdapter.objResults = objResults;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = LayoutInflater.from(ctxContext);
View vewRow = mInflater.inflate(R.layout.row, null);
TextView tvwName = (TextView) vewRow.findViewById(R.id.name);
tvwName.setText(objResults.get(position).getName());
return vewRow;
}
}
From my main activity i.e. the Activity
that initially invoked the AsyncTask
, I would like to do some sorting and filtering operations on the list of results in the SearchResultsAdapter
. How can I do this?
How can I access the adapter rows from my main UI thread because I don't seem to have access to the adapter instance? I also read something about calling notifyDatasetChanged()
or something?
Thanks.