问题
How to do that?
I have AnalogClock on my xml. And I want drawable for the android:dial to change programatically.
I tried
remoteviews.setImageViewResource(R.id.AnalogClock, R.drawable.w0);
or
remoteviews.setInt(R.id.AnalogClock, "setDialResource", R.drawable.w0);
Both can not accomplish it. Anyone manage to do this?
回答1:
Finally make it works. I put transparent image on AnalogClock android:dial Then use FrameLayout to overlay ImageView and AnalogClock.
Then use
remoteviews.setInt(R.id.ImageView, "setBackgroundResource", R.drawable.w0);
to change the ImageView image. It is feasible solution at the moment.
回答2:
Normally remoteviews.setImageViewResource(R.id.AnalogClock, R.drawable.w0)
should do the trick. Are you sure that the View refferenced by R.id.AnalogClock
is of type ImageView
来源:https://stackoverflow.com/questions/9398362/set-drawable-dynamically-for-analogclock-widget