0
我在每行有一個ListView
我有一個LinearLayout
與一些對象(主要是一些TextViews)。SimpleCursorAdapter刪除值
這個ListView我從遊標動態填充它。在這個遊標中,我有一個值true或false。
我想隱藏或使不可點擊的行的值爲false。我試試這個代碼,但該適配器
http://developer.android.com/reference/android/widget/BaseAdapter.html#isEnabled(int)
這個答案似乎它暗示上不起作用
public void contentProviderInitialized(final Cursor cursor) {
SimpleCursorAdapter commonTickets = new SimpleCursorAdapter(MyClass.this,
R.layout.row_ticketing, cursor, new String[] {"price", "productName", "stopName" },
new int[] { R.id.ticketing_price, R.id.ticketing_product, R.id.ticketing_stop_name }
) {
@Override
public void bindView(View view, Context context, Cursor cursor) {
String enabledStr = cursor.getString(cursor.getColumnIndex("enabled"));
String product = cursor.getString(cursor.getColumnIndex("productName"));
boolean enabled = Boolean.parseBoolean(enabledStr);
LinearLayout ticketingRow = (LinearLayout) view.findViewById(R.id.ticketing_row);
if (enabled) {
ticketingRow.setEnabled(true);
} else {
ticketingRow.setEnabled(false);
}
super.bindView(view, context, cursor);
};
MyClass.this.ticketing_list_view.setAdapter(commonTickets);
}
}
發佈完整的異常和您的StackTrace。 –
我沒有提到有關例外情況。問題是具有錯誤值的行仍然是可點擊的。 – tinti