Inheriting the ArrayAdapter class and overwrite the getView function. The getView function always called, when row is displayed.
Create class for rows:
public class MyRow {
public boolean installed;
}
Implement ArrayAdapter:
public class MyAdapter<MyRow> {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.rowlayout, parent, false);
// get actual row item.
MyRow item = (MyRow)getItem(position);
ImageButton ib = (ImageButton)v.findViewById(R.id.install);
ImageButton uib = (ImageButton)v.findViewById(R.id.uninstall);
if (item.installed) {
ib.setVisibility(View.VISIBLE);
uib.setVisibility(View.GONE);
} else {
ib.setVisibility(View.GONE);
uib.setVisibility(View.VISIBLE);
}
return rowView;
}
}
Check this tutorial on how to implement ListAdapter and how to recycle views. http://www.vogella.com/tutorials/AndroidListView/article.html