title: Android - Change the Image View Source at run time after few seconds
body: <p>The following code is for a splash screen in my app.What I need to be done is when the activity loads the image should be displayed as default and then after few seconds the image should be changed to another in the same activity. I have another image like the first one with different color. I wanted to change the screen for that image after few seconds.</p>
  
  <p>I have done it like this in my code.</p>
  
  <pre><code>package com.ruchira.busguru;
  
  import android.media.MediaPlayer;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.graphics.Color;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.ImageView;
  import android.widget.RelativeLayout;
  
  public class SplashScreen extends Activity {
  
      ImageView imgBus;
      MediaPlayer introSound, bellSound;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.splash_screen);
          imgBus = (ImageView) findViewById(R.id.imgBus);
          imgBus.setImageResource(R.drawable.blackbus);
          introSound = MediaPlayer.create(SplashScreen.this, R.raw.enginestart);
          introSound.start();
  
                  Thread timer = new Thread(){
              public void run(){
                  try{
                      sleep(3000);
                  } catch (InterruptedException e) {              
                      e.printStackTrace();
                  }finally{
                     imgBus.setImageResource(R.drawable.bluekbus);    
                  }
              }
          };
          timer.start();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.splash_screen, menu);
          return true;
      }
  
      @Override
      protected void onPause() {
          // TODO Auto-generated method stub
          super.onPause();
          introSound.stop();
          finish();
      }
  
      @Override
      protected void onStop() {
          // TODO Auto-generated method stub
          super.onStop();
          introSound.stop();
          finish();
      }
  }
  </code></pre>
  
  <p>but the problem is the program stops by executing in the thread saying...</p>
  
  <p>"android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views."</p>
  
  <p>How I can achieve this target ? Does anybody please help me to sort out this problem. I am new to android development..</p>
  
  <p>Thanks.</p>