2016-07-26 5 views

答えて

1

回答が見つかりました。 Drawable.ICallbackを実装し、AnimationDrawable.GetFrame()を使用して、必要な各フレームでコールバックを設定します。

private class MyFragment : DialogFragment, Drawable.ICallback 
{ 
    TextView tv; /* this is later defined in OnCreateDialog */ 
    ... 

    /* Must implement */ 
    public void InvalidateDrawable(Drawable who) 
    { 
     /* As you can see in OnCreateDialog(), this gets called for 
      frames 0 and 56 */ 
     if (iVocabIndex == 0) { 
      tv.Text = "Show this text"; 
      iVocabIndex = 1; 
     } 
     else if (iVocabIndex == 1) { 
      tv.Text = "Show this other text"; 
      iVocabIndex = 0; 
     } 
    } 

    /* Must implement */ 
    public void ScheduleDrawable (Drawable who, IRunnable what, long when) 
    { 
    } 

    /* Must implement */ 
    public void UnscheduleDrawable (Drawable who, IRunnable what) 
    { 
    } 

    public override Dialog OnCreateDialog (Bundle savedInstanceState) 
    { 
     ImageView image = view.FindViewById<ImageView> (Resource.Id.confDialogImage); 
     tv = view.FindViewById<TextView> (Resource.Id.confDialogImageText); 
     image.SetImageResource (Resource.Drawable.my_animation_xml); 
     AnimationDrawable b1Anim = (AnimationDrawable)image.Drawable; 
     b1Anim.Start(); 
     Drawable d = b1Anim.GetFrame(0); 
     d.Callback = this; 
     d = b1Anim.GetFrame(56); 
     d.Callback = this; 
    } 
関連する問題