Attempting a fairly simple animation of a View. I'm trying to display a panel, and then just animate it if the user touches the screen.
Code for my simplified test is below. The function animateMe() definitely gets called, but nothing happens. Any help greatly appreciated, thanks. MAIN FILE: public class MovePanelsPCT2 extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.main); setContentView(new DrawView(this)); } } DRAW VIEW CLASS: public class DrawView extends View { private Panel myPanel; Point point0 = new Point(); public DrawView(Context context) { super(context); setFocusable(true); //necessary for getting the touch events point0.x = 20; point0.y = 0; myPanel = new Panel(context,R.drawable.green_panel, point0); } @Override protected void onDraw(Canvas canvas) { canvas.drawBitmap(myPanel.getBitmap(), myPanel.getX(), myPanel.getY() , null); } public boolean onTouchEvent(MotionEvent event) { myPanel.animateMe(); invalidate(); return true; } } PANEL CLASS: public class Panel extends View { private Bitmap img; // the image of the panel private int coordX = 0; // the x coordinate at the canvas private int coordY = 0; // the y coordinate at the canvas private RotateAnimation anim2 = null; public Panel(Context context, int drawable, Point point) { super(context); BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = true; img = BitmapFactory.decodeResource(context.getResources(), drawable); coordX = point.x; coordY = point.y; } public void animateMe (){ anim2=new RotateAnimation(0.0f, 90.0f); anim2.setDuration(1000); anim2.setInterpolator(new AccelerateInterpolator(1.0f)); startAnimation(anim2); } public int getX() { return coordX; } public int getY() { return coordY; } public Bitmap getBitmap() { return img; } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---