Android: get id when Button is clicked
I'm creating a Dictionary that has a bookmark and i want to have an
activity where i can delete individual data in a bookmark.. this is the
sample layout that i want to do
at the left corner of each data there is a button that can delete the item
is there a method of button that can get the _id of the item this is how i
output my data in list view
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));
}
hope you can help me... thanks
No comments:
Post a Comment