Zsombor Erdődy-Nagy
Zsombor Erdődy-Nagy

Reputation: 16914

How to update a single row of a ListView with animation?

I have a ListView with several rows, and the user can start async tasks by pressing buttons on these rows. When a task is started, the corresponding row should show some "Loading" View, and when the task finishes, the row should show the results of that async task.

Functionally, everything is working currently. But I'd like to switch a row's state using animations. Right now, I always call .onDataSetChanged() on the ListView's adapter when a row's state has to change (e.g. Loading -> Some content). But this reloads/redraws the whole ListView.

I only want to modify a single row, and I'd like to do it with a nice animation. AFAIK, you always have to call .onDataSetChanged() on the adapter, whenever the data behind the ListView changes, or else you get an Exception.

So is it possible to somehow load new data into a ListView row, and present it with animation (that affects only the modified row)?

Thanks

Upvotes: 2

Views: 907

Answers (1)

blessanm86
blessanm86

Reputation: 31789

Well 1 way to do it was select the child view and add the animation to that view. And when the animation is done you could update the values for the view. Something like getListView.getChildAt(index).startAnimation(anim);

And add a animation listener to 'anim' so you can update the values when the animation ends.

Upvotes: 3

Related Questions