Delete ListView row in Custom Adapter
I want to delete a row from my list view on click of "delete" button. My
listview item has following things placed horizontally:
TextView-1,TextView-2,TextView-3,ImageButton-delete button. Now when I
click delete button, the row should be deleted from the view. Below is the
adapter code;
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
View view = (View) v.getParent();
TextView tv = (TextView) view.findViewById(R.id.item_name);
String item = tv.getText().toString();
String tableno = mListItems.get(0).getTableNumber();
orderDetailsDB = new OrderDetailsDBAdapter(
getApplicationContext());
orderDetailsDB.deleteItem(item,tableno);
I tried by setting Individual textviews to blank but its not working.
holder.itemName.setText("");
holder.amount.setText("");
holder.quantity.setText("");
I read couple of posts and they suggest to remove item from my
list(mListItems) and then do adapter.notifyDataSetChanged();. Problem is I
am not using array adapter for populating list view but using Custom
adapter, so unable to get the position for item to be deleted. Please
advise. thanks.
No comments:
Post a Comment