Hi,
I just started android and i'm running into some problems.
I have created a listview that is populated from a database.
Each row has a button to delete the item from the list and the database.
I am able to hook up an event listener to the button but I have not been able to determine the matching database record to be deleted.
My class is below
public class FeedArrayAdapter extends ArrayAdapter implements OnClickListener {
private ARssEReaderDBAdapter dba;
private String TAG = "FeedArrayAdapter";
public FeedArrayAdapter(Context context, int textViewResourceId, List<Feed> items) {
super(context, textViewResourceId, items);
Log.w(TAG, "List");
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
Log.w(TAG, "getView");
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.feedlistrow, null);
}
Feed feed = getItem(position);
if (feed != null){
TextView title = (TextView)v.findViewById(R.id.TextView01);
if (title != null){
title.setText(feed.getTitle());
}
Button btnDelete = (Button)v.findViewById(R.id.btnDelete);
btnDelete.setOnClickListener(this); //btnDeleteFeedListener
}
return v;
}
public void onClick(View v){
Log.w(TAG, "something got clicked: ");
}
}
So how can I pass the database record ID to the handler so I can use the database adapter to delete it.
Any help is greatly appreciated.
Kind regards,
Richard