anho
anho

Reputation: 1735

how to refresh listView from its adapter

What would be the best way to refresh the ListView from its BaseAdapter? I am having a ListView that has an adapter. Here one of the views has a button that when the user clicks I would like to refresh a certain view (at position).

I have tried calling the following code in public View getView(int position, final View convertView, final ViewGroup parent), but this doesn't work.

View attendingUsers = parent.getChildAt(11);
attendingUsers.invalidate();

Is there a way to redraw the view?

Upvotes: 3

Views: 3530

Answers (2)

Nadav Finish
Nadav Finish

Reputation: 1160

This will work only for RecyclerView and not for ListView. Use notifyItemChanged (int position, Object payload) it is much more efficient, for more information: notifyItemChanged reference

Upvotes: -1

anho
anho

Reputation: 1735

Calling notifyDataSetChanged(); solved my problem

Upvotes: 2

Related Questions