tags:

views:

39

answers:

2

Hi Everybody,

I created one login screen but before login screen to appear I wanted a image to flash on the screen. For this I use Toast. But the problem is before flashing the Image Login screen appears for a while and the image flashes after that again Login Screen appears. I wants to flash the image first before any thing appears in the screen. Here is my code :

    setContentView(R.layout.main);


    ImageView iv = new ImageView(this);
    iv.setImageDrawable(getResources().getDrawable(R.drawable.start));

    Toast t = new Toast(this);
    t.setView(iv);
    t.show();
    t.setDuration(5);

Thanks Deepak

A: 

Check out this link

It may help you

Nishant Shah
Sorry,, that link does not help me.
Deepak
So, you do not want splash screen before login page
Nishant Shah
I wanted ..but with the help of Toast. Can't I do with the help of Toast. I dont want any animation kind of thing.
Deepak
I don't think it is possible.
Nishant Shah
I have only one image. So is it necessary to use Animation? Cannot I achieve with Toast? Toast is working but the problem is as the Login Activity starts LoginScreen is appear and then Toast displays the image. After that Login Screen again appears? I want to display the Toast before the login screen to appear.
Deepak
+1  A: 

Hi friend

You Need to use Handler Class To Hold the present LoginWindow for few seconds , Handler Class Provides A method which can be used display image before the screens is displayed,

if is not possible with Handler method then please make use of Activity LifeCycle Methods like OnStart() etc there are lot activity methods u can use

Here is some useful code to u..

private Handler handler;
private final static String DEBUG_TAG = "splashScreen";


public void onCreate(Bundle savedInstanceState) {
    Log.i(DEBUG_TAG, "onCreate executes ...");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscr);
    handler = new Handler(); 




}


public void onResume()
{ Log.i(DEBUG_TAG, "onResume executes ...");
handler.postDelayed(new Runnable()
{

    public void run()
    {
        Intent myIntent= new Intent(SplashScreen.this,TabCls.class);
        startActivity(myIntent);    
    }
}, 1000); 

super.onResume();
}


protected void onStart()
{
    super.onStart();
    Log.i(DEBUG_TAG, "onStart executes ...");
}




protected void onRestart()
{
    super.onRestart();
    Log.i(DEBUG_TAG, "onRestart executes ...");
}



protected void onPause()
{   
    super.onPause();
    Log.i(DEBUG_TAG, "onPause executes ...");

}


protected void onStop()
{
    super.onStop();
    Log.i(DEBUG_TAG, "onStop executes ...");
}    

protected void onDestroy()
{ 

    super.onDestroy();

    Log.i(DEBUG_TAG, "onDestroy executes ...");
}

}

Ramesh Bugatha