title: New to Android Help with UI Thread
body: <p>I am trying to make 4 images to be set invisible and visible after a period of time, something like blue image shows, blue image hides, yellow image shows, yellow image hides. I want to do this with no events, only with a for loop. I am trying the following but it's not working. I am new to android and graphics. Please help me</p>
  
  <pre><code>public class GameActivity extends Activity {    
  /** Called when the activity is first created. */
  private Handler mHandler = new Handler();
  ImageView[] imViews = new ImageView[4];
  ImageView imageView1;
  ImageView imageView2;
  ImageView imageView3;
  ImageView imageView4;
  
  @Override  
  public void onCreate(Bundle savedInstanceState) {  
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.myviewlay);
      imageView1= (ImageView)findViewById(R.id.ImageView01);
      imageView2= (ImageView)findViewById(R.id.ImageView02);
      imageView3= (ImageView)findViewById(R.id.ImageView03);
      imageView4= (ImageView)findViewById(R.id.ImageView04);
  
  
      final ImageView[] imViews = new ImageView[4];
      imViews[0] = imageView1;
      imViews[1] = imageView2;
      imViews[2] = imageView3;
      imViews[3] = imageView4;
  
      mHandler.removeCallbacks(mUpdateTimeTask);                         
      mHandler.postDelayed(mUpdateTimeTask, 100); 
  
  }
  
  private Runnable mUpdateTimeTask = new Runnable() {  
       public void run() {   
  
           for(int i=0; i &lt; 5; i++)
           {
                imViews[i].setVisibility(View.INVISIBLE);
                mHandler.postDelayed(this, 1000); 
                imViews[i].setVisibility(View.INVISIBLE);
                mHandler.postDelayed(this, 1000); 
           }
  
           }};   
  }
  </code></pre>
  
  <p>My error log:</p>
  
  <pre><code>04-23 05:25:16.383: ERROR/AndroidRuntime(506): java.lang.NullPointerException
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at com.games.game.GameActivity$1.run(GameActivity.java:60)
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at android.os.Handler.handleCallback(Handler.java:587)
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at android.os.Handler.dispatchMessage(Handler.java:92)
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at android.os.Looper.loop(Looper.java:123)
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at android.app.ActivityThread.main(ActivityThread.java:3647)
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at java.lang.reflect.Method.invokeNative(Native Method)
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at java.lang.reflect.Method.invoke(Method.java:507)
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  04-23 05:25:16.383: ERROR/AndroidRuntime(506):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>