2011-11-03 37 views
0

我使用SimpleCursorAdapter 我想从取决于变量 该适配器删除一些值我尝试这样的事情,但不做工精细光标填充的微调的Android移除值从微调

SimpleCursorAdapter toListAdapter = new SimpleCursorAdapter(MoreTicketSalesActivity.this, R.layout.generic_spinneritem, cursor, column, 
     viewIds) { 


@Override 
public void bindView(View view, Context context, Cursor cursor) { 
    super.bindView(view, context, cursor); 
     if (cursor.getLong(3) < session.getStopIndex()) { 
      view.setVisibility(View.INVISIBLE); 
     } 
    } 
}; 

请帮我

回答

1

所以我找到一个解决方案谁就是适合我

TextView textView = (TextView) view.findViewById(R.id.spinner_item_name); 
int index = cursor.getInt(cursor.getColumnIndex("index")); 
String name = cursor.getString(cursor.getColumnIndex("name")); 
textView.setText(name); 
if (index <= this.index) { 
    textView.setTextColor(Color.LTGRAY); 
    textView.setClickable(true); 
} else { 
    textView.setTextColor(Color.BLACK); 
    textView.setClickable(false); 
} 
0

首先您检查变量的值并获取要从光标删除的项目的位置。

  1. 然后从Cursor中删除这些值(通过删除(值的位置)或等)。

  2. 然后使用toListAdapter.notifyDataSetChanged();

+0

如何从光标删除值...光标是只读的,(我知道)。游标带有值并且是正确的。也许我必须解释更多。我有2个spinners填充相同的光标。停站名称。如果我从“来自”微调器中选择了一些内容,然后在“微调控制器”中,我必须删除从选定停止传递的所有值。 – tinti

+0

为什么不创建字符串数组或列表并使用它。 – AB1209

+0

因为在游标中我有id,index,name。我需要所有这些价值观。我可以列出一个列表,但是我很难渲染微调。 – tinti