I'm playing around building a new widget and was looking at the Android app widget documentation, in particular the section on which widget classes were supported. I noticed that ViewFlipper is supported, but I'm struggling to find any examples on how to use one in a home screen widget. In particular, I'm wondering if its possible to manually trigger swapping views. In an activity this looks relatively straightforward, one example being hooking up the onclick listener of a button to call the showNext() of the flipper.
The RemoteViews object has showNext and showPrevious methods but I'm not sure I understand how to hook them up to an event fired from the user interacting with the widget. Can anyone provide examples of when these methods might be called?
It looks like buttons in widgets can only be wired up to intents rather than code to exercise the flipper. If this restriction is true, then is the only use of a view flipper in an app widget for auto flipping of views?
Say you have 2 buttons: LEFT and RIGHT. First you would attach pending intent to each (here it's triggered from
Service#onStart
:Then, in
AppWidgetProvider
doThis should do it. Now the problem is - this will only work in API 11+ and I just found the hard way that
root.setInt(R.id.scroll, "setDisplayedChild", pos)
will not work in API 7.