Hi,
I use code as shown by you. But the problem is that I am not getting
the screen shown by main.xml file (first screen).
When I press back button from the screen viewed by menu.xml file
(second view), it shows view by main.xml file (so it is there but
doesn't come up). So now I don't understand why it doesn't come up in
first place.


The code is as follows:

package com.naag;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import android.view.Window;
public class naag extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        //No Title bar will be displayed
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);

        class SleepClass implements Runnable
        {
            public void run()
            {
                try
                {
                    Thread.sleep(10000); // wait 10 seconds  but not
getting this..
                }
                catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
            }
        }

                Thread t1 = new Thread(new SleepClass());
                t1.start();

                Intent menuLauch = new Intent (this, menu.class);
                startActivity (menuLauch);

    }
}


The problem is I am not getting delay of 10 second.
I provided delay in menu.java file for 2 sec and it is there.

The menu.java file is as follows...
package com.naag;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;

public class menu extends Activity {
         /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);

        //No Title bar will be displayed
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        try {
                        Thread.sleep (2000);           ///////////////////only 
getting this
delay
                } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        setContentView(R.layout.menu);
    }
}

I have also changed AndroidManifest.xml to use intents..

Also
What I found more is:
These two lines of code also not working properly.

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);

When the application starts, only black screen with Title of Game
comes up. After 2 seconds, the view displayed by menu.xml file comes
up. (Actully it should display first screen provided by main.xml and
that is also without Title bar and when I press back button from menu,
it shows main screen without title bar).
So don't uderstand when I am messing up.
-------------------------------------------------------------------------------------------------------------------------------

The viewflipper is a good idea but its not useful in my application.
Thanks for that information.

Also by changing  setContentView(R.layout.menu); after  setContentView
(R.layout.main); doesn't help.
As it provides only second view and that is without first even show up
and its not there in history stack.

So please help me in this problem.

Thanks for your replies.

On Nov 11, 8:32 am, Mark Murphy <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
> > I am developing a game.
> > When the game starts, it shows one screen (Splashscreen).I have
> > created xml file for that which contains only backgroudn. Nothing
> > else.
>
> > I want that after some time (2 sec proabably), it should switch to the
> > new view, which shows the menu for the game. Now I have created xml
> > for that also.
> > What I want is
> > [1] When view for menu loads, and if user presses back, user should
> > not get that splashscreen back.
> > [2] The view should be changed automaticlly (from splash to menu). And
> > I m not sure, that how can I do this. I googled and what I found is I
> > have to create activities for each views and create diffrent java file
> > for that and use Intent to call the view, But I don't find any code
> > that properly explain this.
>
> 1. You can use ViewFlipper to hold both the splash screen and the menu
> in the same layout file. Then, in onCreate(), use View#postDelayed() to
> trigger a switch to the menu after so many seconds.
>
> 2. You apparently can call setContentView() multiple times without
> problems, though I have not tried this. So, in onCreate(), you would
> call setContentView() for the splash screen, then use View#postDelayed()
> to call setContentView() for the menu.
>
> In either case, you have a single activity.
>
> I have a blog post up describing the ViewFlipper technique, though it is
> for an older SDK and may require fixes to the poorly-formatted source code:
>
> http://androidguys.com/?p=654
>
> ViewFlipper also makes it easy to set up custom animations for
> transitioning from the splash screen to the menu.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 1.4 Published!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to