I have a extended SimpleCrussorAdopter which returns one of two views based on some condition.
public ListAdapter(Context context, int layout, Cursor c, String[] from,
int[] to, int flags) {
super(context, layout, c, from, to, flags);
}
@Override
public int getViewTypeCount() {
return 2;
}
@Override
public int getItemViewType(int position) {
if(condition == true) return 1;
else return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView ;
if( getItemViewType(position) == 1){
if(convertView == null){
convertView = inflater.inflate(R.layout.row1, parent, false);
rowView = (View)convertView;
}else
{
rowView = (View)convertView;
}
}else
{
//inflate and the second view row2, in the above manner
} return rowView;
}
Below is the View Binder:
adapter.setViewBinder(new PuzzleListAdapter.ViewBinder() {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
int percent = cursor.getColumnIndex(PuzzleDatabase.KEY_PUZZLE_PERCENT_COMPLETED);
if (percent == columnIndex) {
ProgressBar pbar = (ProgressBar) view ;
int progress = cursor.getInt(columnIndex);
pbar.setProgress(progress);
return true;
}
return false;
}
});
This View winder works perfectly with an object of SimpleCrussorAdapter.
What could be the problem
Problem 1: If I extend SimpleCrussorAdaptor, its not able to use its parents class capability to bind croussor col columns with views.
Problem 2: With extended SimpleCrussorAdaptor custon view binder is also not working.
Am I missing something.