I having a widget in my app,widget contains some ImageView 's but i need to animate the views in the widget,with using ViewFlipper i can do it, but it support from API+11,how can i make it in below versions,even if possible in any other way be appereciated
public class MyAnimationWidget extends AppWidgetProvider {
private Handler handler;
private Context context;
private Runnable myRunnnable = new Runnable() {
@Override
public void run() {
updateWidget(context);
handler.postDelayed(this, 1000);
}
};
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
this.context = context;
if (handler == null) {
handler = new Handler();
handler.postDelayed(myRunnnable, 2000);
}
}
private void updateWidget(Context context) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
R.layout.activity_main);
remoteViews.showNext(R.id.view_flipper);
ComponentName componentName = new ComponentName(context,
MyAnimationWidget.class);
AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
widgetManager.updateAppWidget(componentName, remoteViews);
}
}
here is my widget_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/myshape"
android:orientation="vertical" >
<ViewFlipper
android:id="@+id/view_flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inAnimation="@anim/in_from_left"
android:outAnimation="@anim/out_to_right" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:src="@drawable/algeria" />
</ViewFlipper>
</LinearLayout>