XML : Android widget - set frame-by-frame Animation in imageview

i'm trying to develop widget for android and this my code for now

Mainactivity xml

  <?xml version="1.0" encoding="utf-8"?>  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"  android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"  android:paddingRight="@dimen/activity_horizontal_margin"  android:paddingTop="@dimen/activity_vertical_margin"  android:paddingBottom="@dimen/activity_vertical_margin"  tools:context=".MainActivity"  android:transitionGroup="true">    <ImageView      android:layout_width="70dp"      android:layout_height="100dp"      android:background="@drawable/frame1"      android:id="@+id/myimg"      android:layout_centerHorizontal="true"         />          </RelativeLayout>    

mainactivity code

  public class MainActivity extends AppWidgetProvider{      public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds) {      for(int i=0; i<appWidgetIds.length; i++){          int currentWidgetId = appWidgetIds[i];          String url = "http://www.google.com";              Intent intent = new Intent(Intent.ACTION_VIEW);          intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);          intent.setData(Uri.parse(url));              PendingIntent pending = PendingIntent.getActivity(context, 0,intent, 0);          RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.activity_main);                  views.setOnClickPendingIntent(R.id.myimg, pending);                appWidgetManager.updateAppWidget(currentWidgetId,views);          Toast.makeText(context, "widget added", Toast.LENGTH_SHORT).show();      }  }      }    

this work fine crate and when i press button open www.google.com

my question that i have this animate frames

animation.xml

  <?xml version="1.0" encoding="utf-8"?>  <animation-list xmlns:android="http://schemas.android.com/apk/res/android"  android:oneshot="false">  <item android:drawable="@drawable/frame1" android:duration="100" />  <item android:drawable="@drawable/frame2" android:duration="100" />  <item android:drawable="@drawable/frame1" android:duration="100" />  <item android:drawable="@drawable/frame2" android:duration="100" />    </animation-list>    

what i want is to display this animation frame on my widget instead of my current image , what i have to change in my code to do this ?

No comments:

Post a Comment