hi,  I am new to android and I could nt able to solve this, I want to
create a button and with the click of the button the animation should
happen , whats the wrong with this , please help me with the sample
code

Help is always appreciated
Thanks



package com.transformation;

//import android.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.LinearLayout;
public class Transformation extends Activity implements
AnimationListener {
  LinearLayout layout;
  LinearLayout layout2;
  Animation movement;
  Animation movement2;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
   final Button button = (Button)findViewById(R.id.widget40);
   button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {


            public void startAnimation(View v)

                // Get the layouts
                layout = (LinearLayout) findViewById(R.id.linearLayout1);
                layout2 = (LinearLayout) findViewById(R.id.linearLayout2);

                // Create animation for right image
                movement = AnimationUtils.loadAnimation(this,
R.layout.animation_test);
                movement.reset();
                movement.setAnimationListener(this);

                // Create animation for left image
                movement2 = AnimationUtils.loadAnimation(this,
R.layout.animation_test2);
                movement2.reset();
                movement2.setAnimationListener(this);


                // Start animation on each image
                layout2.startAnimation(movement2);
                layout.startAnimation(movement);}

              // Listen for animations to be finished
              // There are more efficient ways, I'm just being lazy.
              public void onAnimationEnd(Animation animation) {
                layout.setVisibility(View.INVISIBLE);
                layout2.setVisibility(View.INVISIBLE);
                // or do whatever it is you wanted to do here, like launch
another activity?
              }

              public void onAnimationRepeat(Animation animation) {
              }

              public void onAnimationStart(Animation animation) {
            }
            });


            }

@Override
public void onAnimationEnd(Animation animation) {
        // TODO Auto-generated method stub

}

@Override
public void onAnimationRepeat(Animation animation) {
        // TODO Auto-generated method stub

}

@Override
public void onAnimationStart(Animation animation) {
        // TODO Auto-generated method stub

}
          };

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to