0

I have a animation list contains the following items

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res
/android"android:oneshot="true">

 <item
    android:drawable="@drawable/b1"
    android:duration="500"/>

<item
    android:drawable="@drawable/delay"
    android:duration="1000"/>

<item
    android:drawable="@drawable/b1"
    android:duration="500"/>

<item
    android:drawable="@drawable/delay"
    android:duration="1000"/>
<item
    android:drawable="@drawable/b2"
    android:duration="500"/>

Now, when the animation is running or has started by the following
code,

img1 = (ImageView)findViewById(R.id.stimulichangeid);
img1.setBackgroundResource(R.drawable.erp_simple_presentationlist1);
AnimationDrawable splashanimation = (AnimationDrawable)img1.getBackground();
splashanimation.start();

I want to click some button when in animation list "b2" drawable
appears on the imageview.But in a running animation, how to access a
particular item(in my case b2). When b2 comes i want to press a button and do something. i was thinking to assign id's to every item. if yes, then how to access that particular item with its id when the
animation is running. please suggest some way to solve this problem. thanks in advance

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
user3206535
  • 25
  • 1
  • 8

1 Answers1

0

AnimationDrawable isn't kind of layout so you can't catch any child view with order. It just replaces a drawable with a new one, so you need a kind of listener returns the order of new drawable. And native implementation doesn't have these kind of listener.

There is some custom AnimationDrawables and you can modify one of these for your need.

Community
  • 1
  • 1
asozcan
  • 1,370
  • 1
  • 17
  • 24