Run progress bar while switching Activity
<p>im stuck in a situation where i am switching from activity 1 to activity 2.
i am using Thread.sleep(5000) to start another activity after 5 seconds
But the progress bar which i want to run for five seconds also sleeps with the first activity
Pleaze help me as to when i click next Button on first activity a progress bar shoud run for five sec
and then activity should be loaded
My Code is:</p>

<pre><code>    public class Activity1 extends Activity  {          
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Button next = (Button) findViewById(R.id.B);
    final ProgressBar  p=(ProgressBar) findViewById(R.id.pr);
    next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
              p.setVisibility(4);
            Thread t=new Thread();
            try{                    
                t.sleep(5000);              

        }
            catch(Exception e){}

            Intent myIntent = new Intent(view.getContext(), activity2.class);
            startActivityForResult(myIntent, 0);
        }

    });   

}}
</code></pre>
