Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could try setting a repeat count on your Animation to imagecount-1, then adding an AnimationListener to your animation that changes the background image of the ImageView on every repeat and on start.</p> <p>Here's a simple example that uses RoboGuice (which makes the code cleaner but doesn't make any difference for the purposes of your question): <a href="https://github.com/bostonandroid/batgirl/blob/master/src/org/roboguice/batgirl/Batgirl.java" rel="nofollow">https://github.com/bostonandroid/batgirl/blob/master/src/org/roboguice/batgirl/Batgirl.java</a></p> <pre><code>public class Batgirl extends RoboActivity { // Views @InjectView(R.id.content) LinearLayout linearLayout; // Resources @InjectResource(R.anim.spin) Animation spin; @InjectResource(R.integer.max_punches) int MAX_PUNCHES; // Other Injections @Inject ChangeTextAnimationListener changeTextAnimationListener; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Set up the animation linearLayout.setAnimation(spin); spin.setAnimationListener(changeTextAnimationListener); spin.setRepeatCount(MAX_PUNCHES - 1); spin.start(); } } /** * A simple animation listener that swaps out the text between repeats. */ class ChangeTextAnimationListener implements AnimationListener { @InjectView(R.id.hello) TextView helloView; @Inject Fist fist; @Inject PackageInfo info; public void onAnimationRepeat(Animation animation) { onAnimationStart(animation); } public void onAnimationStart(Animation animation) { helloView.setText( getNextTextString() ); // getNextTextString() not shown in this example } public void onAnimationEnd(Animation animation) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload