Reputation: 4620
I'm using listview animation from API DEMOS, example 2. here's the snippet from OnCreate method:
ListView listview = (ListView) findViewById(android.R.id.list);
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(50);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(200);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
listview.setLayoutAnimation(controller);
At some point in the future, notifyDataSetInvalidated()
is called upon list's adapter, and my list is refreshed. but the items are not shown in animation any more.
Please help.
Upvotes: 1
Views: 6746
Reputation: 19220
You should check out this thread about difference between notifyDataSetChanged() and notifyDataSetInvalidated() (Link updated to point to Romain Guy's answer!)
In short the difference is:
notifyDataSetChanged
: The items in the data set are changed (added / removed / updated / reordered, whatever). notifyDataSetInvalidated
: The data source of the adapter is no longer available.Here you can find a working sample with notifyDataSetInvalidated
function in use. Probably it will do the trick with your animation problem as well.
Upvotes: 0
Reputation: 2117
If you want to reanimate your LayoutController after your data set changes, call the method startLayoutAnimation() of the view.
Upvotes: 3