I have a list view made using custom Adapter & contains 2 text view in each row, I want to update data of rows , when I long pressed on row.
Asked
Active
Viewed 446 times
1
-
2change data in onLongPress and call notifyDataSetchanged() method – Abhishek Jaiswal Dec 26 '16 at 10:12
-
@user6299305 you can share code snippet also, if you want more clarity..! – Mohammad Misbah Dec 26 '16 at 10:21
3 Answers
2
Just update your model object according to the need and call notifyDataSetChanged()
inOnLongClickListener
or OnItemLongClickListener
of ListView. List data will update.

Mohammad Misbah
- 870
- 8
- 19
1
Go to your custom adapter, and set an OnLongClickListener
on the view you return in getView()
. In the OnLongClickListener
update the array or list you are using and when finished, call notifyDataSetChanged()
on the ListView.

Sean Goudarzi
- 1,244
- 1
- 10
- 23
0
Try this:
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
int pos, long id) {
adapter.notifyDataSetChanged();
return true;
}
});

Nick Titov
- 588
- 5
- 19