Reputation: 17119
I'm trying to disable certain items in my ListView by the following code
public class VSsimpleCursorAdapter extends SimpleCursorAdapter implements
Filterable {
public VSsimpleCursorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) {
super(context, layout, c, from, to);
}
public boolean areAllItemsEnabled() {
return false;
}
public boolean isEnabled(int position) {
String s = "mystring"
if (/*compare an entry in cursor with s*/){
return false;
} else
return true;
}
}
The problem is isEnabled
only has one argument position. How do I use the Curser
used to set the Adapter
in isEnabled
?
Upvotes: 0
Views: 90
Reputation: 1154
Didn't tested it but I guess you just have to move the cursor to the specific row and get the value that should be compared to s. so something like
public boolean isEnabled(int position) {
String s = "mystring";
// the database column of the value that you want to compare to s
int column = 0;
Cursor cursor = getCursor();
cursor.moveToPosition(position);
String value = cursor.getString(column);
if (s.equals(value)) {
return false;
} else
return true;
}
Upvotes: 1