So I have a List of job names in a ListView
that is generated by a custom adapter that extends BaseAdapter
. All items are shown as grayed out initially. For each item, I send an async request through a web service in order to get the status of this job. At the same time, I show an indefinite progress bar in each row. Everytime a response is received, a callback method onSuccess(int itemPosition) gets called for that particular item. itemPosition is the index of the item in the List. In this method I want to set the color of the Text according to received status AND remove the progress bar. I tried the following with no luck:
public void onSuccess(int itemPosition, int status) {
View convertView = getLayoutInflater().inflate(R.layout.rowlayout, null);
((ProgressBar)convertView.findViewById(R.id.progressbar)).setVisibility(ProgressBar.GONE);
if(status == READY)
((TextView)convertView.findViewById(R.id.jobname))
.setTextColor(status == READY ? Color.GREEN : Color.RED);
mListViewAdapter.getView(itemPosition, convertView, null);
}
Any ideas how I should handle this?