0
我想旋转与触摸事件的计时器的图片。我创建了一个没有定时器/线程的方法。但是当我在计时器中使用它时,它不起作用。我不擅长android编程。旋转图片与触摸事件与计时器
----------->这是ontouch事件
@覆盖
public boolean onTouch(View v, MotionEvent event){
t1=new TimerTask()
{
public void run()
{
angle += 40;
spin(angle);
if(angle >=360)
angle = 0;
}
};
t.schedule(t1,2*1000);
return false;
}});
---------->这是我的自旋方法
public void spin(int degree)
{
Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
Matrix mat = new Matrix();
mat.postRotate(degree);
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, bMap.getWidth(), bMap.getHeight(), mat, true);
bottle.setImageBitmap(bMapRotate);
}
感谢您的关注。我希望它能够工作几次..我的意思是,我需要某种循环.. – ertan2002 2012-03-15 15:36:06
然后,您可以将相同的代码与'android.os.Looper'结合使用,并使用Looper循环多次.loop() – Rajkiran 2012-03-15 15:38:52
thanx回答..它确定:)而且我也解决了它..这里是我的代码.. http://pastebin.com/T2KKrk5z – ertan2002 2012-03-15 15:42:11