我试图在按钮点击时在我的小部件内播放刷新按钮旋转动画。我试着这样做:
RotateAnimation anim = new RotateAnimation(0f, 360f, 15f, 15f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(700);
// Start animating the image
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ImageView image = (ImageView) inflater.inflate(R.layout.main, null).findViewById(R.id.refreshBtnImageView);
image.startAnimation(anim);
但它不起作用。我的刷新按钮位于小部件内,我正在侦听BroadcastReceiver中的按钮单击。我可以在BroadcastReceiver中像这样引用ImageView,还是需要使用RemoteViews?如果是RemoteViews,那么我该如何应用动画?
谢谢!