

jpe30 wrote:I'm having the same problem as ashy, the setVisibility(View.GONE) line throws a null pointer exception. I need this as I need to show 2 splash screens, one right after the other.
Any suggestions as to how to get this working?

package com.helloworld;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}package com.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
public class splashscreen extends Activity {
private static final int STOPSPLASH = 0;
//time in milliseconds
private static final long SPLASHTIME = 5000;
private ImageView splashscreen;
//handler for splash screen
private Handler splashscreenHandler = new Handler() {
/* (non-Javadoc)
* @see android.os.Handler#handleMessage(android.os.Message)
*/
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case STOPSPLASH:
//remove SplashScreen from view
splashscreen.setVisibility(View.GONE);
break;
}
super.handleMessage(msg);
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
splashscreen = (ImageView) findViewById(R.id.splashscreen);
Message msg = new Message();
msg.what = STOPSPLASH;
splashscreenHandler.sendMessageDelayed(msg, SPLASHTIME);
}
}
Users browsing this forum: Exabot [Bot] and 6 guests