Android 如何在小部件内的ImageView上应用RotateAimation

Android 如何在小部件内的ImageView上应用RotateAimation,android,android-layout,android-widget,Android,Android Layout,Android Widget,我正在尝试在我的小部件中单击按钮时播放刷新按钮旋转动画。我试着做: RotateAnimation anim = new RotateAnimation(0f, 360f, 15f, 15f); anim.setInterpolator(new LinearInterpolator()); anim.setRepeatCount(Animation.INFINITE); anim.setDuration(700); // Start animating the image LayoutInfl

我正在尝试在我的小部件中单击按钮时播放刷新按钮旋转动画。我试着做:

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中像这样引用ImageView吗,还是需要使用RemoteView?如果是RemoteView,那么如何在其上应用动画

谢谢