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

ResourceAnimationAdapter

nhaarman edited this page Apr 9, 2013 · 1 revision

You can use your animations from resource using the ResourceAnimationAdapter class.

Steps to implement

  • Create a class MyResourceAnimationAdapter which extends the ResourceAnimationAdapter class.
  • Add the default constructor MyResourceAnimationAdapter(BaseAdapter, Context).
  • Implement the methods getAnimationResourceId(), getAnimationDelayMillis(), getAnimationDurationMillis().
  • Use the MyResourceAnimationAdapter class on your ListView.

Example

public class MyResourceAnimationAdapter extends ResourceAnimationAdapter{

    public MyResourceAnimationAdapter(BaseAdapter baseAdapter, Context context) {
    	super(baseAdapter, context);
    }

    @Override
    protected int getAnimationResourceId() {
	    return R.anim.swing_right_in;
    }

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

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

The animation resource file should be of a Property Animation type.