Android Open Source - AndroidViewAnimations My Activity

From Project

Back to project page AndroidViewAnimations.


The source code is released under:

MIT License

If you think the Android project AndroidViewAnimations listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.daimajia.androidanimations;
/*  w  ww .ja  v  a2 s .  c  o  m*/
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.daimajia.androidanimations.library.Techniques;
import com.daimajia.androidanimations.library.YoYo;
import com.nineoldandroids.animation.Animator;

public class MyActivity extends Activity {

    private ListView mListView;
    private EffectAdapter mAdapter;
    private View mTarget;

    protected void onCreate(Bundle savedInstanceState) {
        mListView = (ListView)findViewById(;
        mTarget = findViewById(;
        mAdapter = new EffectAdapter(this);
        rope = YoYo.with(Techniques.FadeIn).duration(1000).playOn(mTarget);// after start,just click mTarget view, rope is not init 
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Techniques technique = (Techniques)view.getTag();
                rope =  YoYo.with(technique)
                            .interpolate(new AccelerateDecelerateInterpolator())
                            .withListener(new Animator.AnimatorListener() {
                                public void onAnimationStart(Animator animation) {


                                public void onAnimationEnd(Animator animation) {


                                public void onAnimationCancel(Animator animation) {
                                    Toast.makeText(MyActivity.this, "canceled", Toast.LENGTH_SHORT).show();

                                public void onAnimationRepeat(Animator animation) {

        findViewById( View.OnClickListener() {
            public void onClick(View v) {
                if (rope != null) {
    private YoYo.YoYoString rope;

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == {
            startActivity(new Intent(this,ExampleActivity.class));
            return true;
        return super.onOptionsItemSelected(item);

Java Source Code List