Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change 'android:autoStart' attribute of ViewFlipper in RemoteViews programmatically?

I am building an appWidget that has multiple views and flips the views. Basically, it's working. But I have no idea how I can stop view flipping in RemoteViews programmatically.

this is xml layout for flipping

<ViewFlipper android:id="@+id/vf_slot_0"
    android:layout_width="fill_parent" android:layout_height="75dp"
    android:autoStart="true"
    android:flipInterval="10000">

and this is the code

RemoteViews mViews = new RemoteViews(context.getPackageName(), R.id.flipping_view);
mViews.setBoolean(R.id.vf_slot_0, "setAutoStart", false);
mViews.setInt(R.id.vf_slot_0, "setFlipInterval", 1000);

'setFlipInterval' is working. I can change flipping interval programmatically by using this code. But 'setAutoStart' isn't. And getting this error..

08-19 01:45:38.821: WARN/AppWidgetHostView(2889): android.widget.RemoteViews$ActionException: view: android.widget.ViewFlipper can't use method with RemoteViews: setAutoStart(boolean)

Wondering why I can't use 'setAutoStart' while I can use 'setFlipInterval'. Is there any way I can start or stop flipping images in my appWidget programmatically?

like image 918
juniano Avatar asked Nov 13 '22 18:11

juniano


1 Answers

I am trying to locate where I read this, but if I recall correctly, the ViewFlipper stops if set to invisible. But I can't seem to find it now. So, if that is true try:

mViews.setViewVisibility(R.id.vf_slot_0, View.INVISIBLE); 
like image 116
AndroidKen Avatar answered Nov 29 '22 06:11

AndroidKen