0
我收到了ContentProvider,它提供了一些內容,例如過濾器。 這些將在ListView中呈現。因爲過濾器有很多字段需要爲列表項創建一個自己的視圖。這些字段映射到擴展CursorAdapter的類中。在CursorAdapter中保存URI/id
public void bindView(View view, Context context, Cursor cursor) {
TextView searchPattern = (TextView) view.findViewById(R.id.tv_searchpattern);
TextView searchType = (TextView) view.findViewById(R.id.tv_searchtype);
int type = cursor.getInt(FilterProvider.SEARCH_TYPE_COLUMN);
[...]
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final View view = inflater.inflate(R.layout.group_list_item, parent, false);
return view;
}
但現在我想知道如何將「內容uris」與列表項一起「攜帶」。 這樣我以後可以輕鬆地檢索它們以便對項目進行操作(例如更新,刪除)?
使用View.id字段是一個好主意嗎?
view.setId(cursor.getInt(FilterProvider.KEY_COLUMN));
還是我完全在錯誤的軌道上?我需要擔心,因爲Integer實際上是Sqlite中的一個Long嗎?