Delete A Row From A Listview Android
I have three textviews and a button in each row of my listview , on button click i want to remove the paticular row from the listview. I have tried many codes but without any succe
Solution 1:
use this:
finalintlistItemPosition= position;
Button b=(Button)row.findViewById(R.id.cancelbutton);
b.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View arg0) {
foodname.remove(listItemPosition);
VivzAdapter.this.notifyDataSetChanged();
}
});
note that you can delete just foodname because that just passed to super constructor, I think you should declare objects and send that object to arraylist, like this :
classobject {
String foodname;
String quantity;
String amount;
}
and use that like this
VivzAdapter(Context c,ArrayList<object>){
}
hope help you!!!
Post a Comment for "Delete A Row From A Listview Android"