2011-11-11 12 views
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); 
    } 
} 
+0

完全な例外とStackTraceを送信してください。 –

+0

私は例外について何も言わなかった。問題は、false値を持つ行がまだクリック可能であることです。 – tinti

答えて

1

オーバーライドISENABLEDを動作しません。カーソルの上で動かす。パフォーマンスが悪いように聞こえるので、数字の位置に基づいて真偽値のキャッシングをしたいかもしれませんか?やってみて。それがどうなるか見てみましょう。キャッシングは無駄かもしれません。

関連する問題