Search code examples
androidandroid-appwidgetremoteview

Android app widget with AdapterViewFlipper clear state


I'm developing app widget using AdapterViewFlipper and I have custom datasource with some elements.
The problem is that when datasource changes the position remains the same. I need reset position when it happens, something like setPosition(0), but RemoteView does not conteins this method.
I've tried to use notifyAppWidgetViewDataChanged and reuse remoteViews.setRemoteAdapter(R.id.page_flipper, intent);
but it did not help.

Is there a better way than this ?

private resetPosition(int currentPage){
   for(int i=currentPage; i>0; i--){
       rv.showPrevious(R.id.page_flipper);
   }
}

Solution

  • I found solution!

    rv.setDisplayedChild(R.id.page_flipper, 0);