Hello All - Here is my problem. I have an ImageView that listens for
an onTouch Event so that when the ImageView is touched, it moves
across the screen. This works, but afterward the onTouch Event is
fired when you touch the original location of the ImageView, rather
than the new translated location.
ie - I touch an image and it moves. i touch it again and nothing
happens, BUT if i go and touch the part of the screen where the image
was originally the image will move again.
the simplified code is below.
thanks alot!
**CODE**
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
rl = (RelativeLayout) findViewById(R.id.inner);
ImageView iv = new ImageView(this);
View.OnTouchListener otl = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent e) {
transAnimate((ImageView)v);
return true;
}
};
iv.setImageResource(R.drawable.icon);
iv.setOnTouchListener(otl);
rl.addView(iv);
}
public void transAnimate(ImageView iv) {
TranslateAnimation trans = new TranslateAnimation((float)0, (float)
Math.random() * 200,(float)0, (float) Math.random() * 360);
trans.setFillAfter(true);
trans.setDuration(3750);
iv.startAnimation(trans);
}
--
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