Note that there are some explanatory texts on larger screens.

plurals
  1. POAnimation, delay
    primarykey
    data
    text
    <p>I would like to make an animation, I have 10 images of a ball and I want to do:</p> <ol> <li><code>Image1</code> visible, all the other images hidden </li> <li><code>Image2</code> visible all the other images hidden </li> <li>... </li> <li><code>Image10</code> visible all the other images hidden</li> </ol> <p>Should I do that in one animation (how?) or should I create a java method showImage(String pathimage) which would show the image located at pathimage and hide the others? Could I put any idea of time delay with using</p> <pre><code>handler.postDelayed(new Runnable() { public void run() { } } </code></pre> <p><strong>EDIT, here is my code</strong> The problem is that run() is always called in what seems to be an infinite loop. But I don't see where is my error</p> <p>GAMEACTIVITY</p> <pre><code> protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ..... ImageView image2 = (ImageView) findViewById(R.id.imageView3); image2.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View arg0, MotionEvent arg1) { myAsyncRunnable mar = new myAsyncRunnable(GameActivity.this); mar.execute(null); PhotoTask photoTask = new PhotoTask(camera,surfaceCamera,isPreview,holder,GameActivity.this); photoTask.execute(null); Log.w("GAMEACTIVITY","PHOTOTASK"); return false; } }); } </code></pre> <p>My Async Task</p> <pre><code>public class myAsyncRunnable extends AsyncTask&lt;Void, Boolean, Void&gt; { GameActivity gameactivity; @Override protected Void doInBackground(Void... params) { pull(); return null; } public myAsyncRunnable(GameActivity gameactivity) { super(); this.gameactivity = gameactivity; } public void pull() { final ImageView image3 = (ImageView) gameactivity.findViewById(R.id.imageView3); final int drawables[] = new int[] {R.drawable.pull2,R.drawable.pull3,R.drawable.pull4,R.drawable.pull5,R.drawable.pull6,R.drawable.pull7}; Runnable runnable = new Runnable() { @Override public void run() { for (int i=0;i&lt;drawables.length;i++) { image3.setImageResource(drawables[i]); gameactivity.handler.postDelayed(this, 500); Log.w("asyncrunnable","run"+i); } } }; gameactivity.handler.post(runnable); } } </code></pre>
    singulars
    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. 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