Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

SingleAnimationAdapter

nhaarman edited this page Apr 9, 2013 · 1 revision

You can apply a single animation to your ListView using the SingleAnimationAdapter class.

Steps to implement

  • Create a class MySingleAnimationAdapter which extends the SingleAnimationAdapter class.
  • Add the default constructor MySingleAnimationAdapter(BaseAdapter).
  • Implement the methods getAnimator(ViewGroup, View), getAnimationDelayMillis(), getAnimationDurationMillis().
  • Use the MySingleAnimationAdapter class on your ListView.

Example

public class MySingleAnimationAdapter extends SingleAnimationAdapter {

	public MySingleAnimationAdapter(BaseAdapter baseAdapter) {
		super(baseAdapter);
	}

	@Override
	protected Animator getAnimator(ViewGroup parent, View view) {
		return ObjectAnimator.ofFloat(view, "translationY", 500, 0);
	}

	@Override
	protected long getAnimationDelayMillis() {
		return DEFAULTANIMATIONDELAYMILLIS;
	}

	@Override
	protected long getAnimationDurationMillis() {
		return DEFAULTANIMATIONDURATIONMILLIS;
	}
}

This particular example will animate the list items in from below.