I'm fairly new at this, so take the following with a grain of salt.

Android has a UI thread, which is the only place things render. While
Screen1.onStart() is running, it's occupying the UI thread, so
nothing, including screen1, can be displayed to the user. Thread.sleep
() just keeps the UI occupied for longer; it doesn't give it an
opportunity to show screen1.

Instead, you have to yield the UI thread for some time. The way to do
this seems to be a Handler (http://developer.android.com/reference/
android/os/Handler.html). For your case, one way to do it might be:

public class Screen1 extends ... {
  private final Handler m_handler = new Handler();
...
public void onStart(){
  super.onstart();
  m_handler.postDelayed(new Runnable() {startActivity(new Intent
(this,Screen2.class));},
          1000 /* ms */);
 }

Hope that helps,
Jeffrey

On Feb 20, 10:18 pm, guptha <gjango...@gmail.com> wrote:
> hi friends,
> i have two layouts for scrren:1 and screen:2
> all i need to make screen:1 appear momentarily before screen:2 appears
> i code looks like :
>
> public class Screen1 extends ...
>  public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.screen1);
> public void onStart()
> {  super.onstart(); startActivity(new Intent(this,Srceen2.class));  }
>
> In Screen2 class
>
> public class Screen2 extends ...
>  public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.screen2);
>
> when i run the apk the screen2 appears .now how to make scrren1 appear
> momentarily ,
>  I tried to insert a code "Thread.sleep(..)  in onstart()  to make my
> first screen1 appear momentarily ,but in vain
> Please help
> Thanks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to