Skip to content

Instantly share code, notes, and snippets.

@teppeihomma
Created July 17, 2012 16:29
Show Gist options
  • Save teppeihomma/3130455 to your computer and use it in GitHub Desktop.
Save teppeihomma/3130455 to your computer and use it in GitHub Desktop.
スプラッシュ画面表示Activity
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
public class SplashActivity extends Activity implements OnClickListener,
Runnable {
/**
* 自動で画面を切り替えるまでの待ち時間
*/
private static final long DELAY_MSEC = 1000;
private static Handler handler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.splash);
View view = this.findViewById(R.id.splashScreenView);
view.setOnClickListener(this);
handler.postDelayed(this, DELAY_MSEC);
}
@Override
public void onClick(View v) {
/**
* 画面タッチでも次の画面へ遷移
*/
handler.removeCallbacks(this);
this.run();
}
@Override
public void run() {
Intent intent = new Intent(this, MainActivity.class);
this.startActivity(intent);
this.finish();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment