0
私はListView
を各行に持っています。私はLinearLayout
の中にいくつかのオブジェクト(ほとんどはTextViews)を持っています。SimpleCursorAdapterは値を削除します
このListView私は動的にカーソルから入力します。このカーソルには、1つの値が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を送信してください。 –
私は例外について何も言わなかった。問題は、false値を持つ行がまだクリック可能であることです。 – tinti