我正在创建一个带有书签的字典,并且我想要一个活动,我可以在其中删除书签中的单个数据。这是我想要做的示例布局
在每个数据的左角有一个可以删除项目的按钮 有没有一个按钮方法可以获取项目的_id 这就是我在列表视图中输出数据的方式
ourCursor = dbDictionaryHelper.getBookmarked();
startManagingCursor(ourCursor);
adapter = new DeleteBookmarkAdapter(ourCursor);
lvDeleteBookmark.setAdapter(adapter);
class DeleteBookmarkAdapter extends CursorAdapter {
DeleteBookmarkAdapter(Cursor c) {
super(DeleteBookmarkActivity.this, c);
}
public void bindView(View row, Context ctxt, Cursor c) {
DictionaryHolder holder = (DictionaryHolder) row.getTag();
holder.populateFrom(c, dbDictionaryHelper);
}
public View newView(Context ctxt, Cursor c, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(R.layout.deletebookmarkdata, parent,
false);
DictionaryHolder holder = new DictionaryHolder(row);
row.setTag(holder);
return (row);
}
}
static class DictionaryHolder implements OnClickListener {
private TextView word = null;
private Button btnRemove = null;
DictionaryHolder(View row) {
word = (TextView) row.findViewById(R.id.tvDeleteBookmark);
}
void populateFrom(Cursor c, DictionaryHelper r) {
word.setText(r.getName(c));
}
希望你能帮助我...谢谢