Witam. Używam Splash Screen
do mojego programu. I w pliku Splash Screen.java znajdują się public class
i private class
. I chce zaby po naciśnięciu przycisku kod w private class
przestał wykonywać polecenia aż do restartu programu.
Ps.Konkretnie chodzi mi o przycisku pomijającego Splash Screen
Ps.Jestem początkujacy w javie, ale trochę wiem.
Ps.Kod przepisywalęm z telefonu więc moga być błędy przy przepisywaniu.
KOD:
public class SplashScreen extends Activity {
Button b;
private static final int CZAS = 5000;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splashscreen);
b1=(Button) findViewById(R.id.Button);
OnClickListener l = new OnClickListener(){
public void onClick(View arg0){
Intent intent = new Intent(SplashScreen.this , MainActivity.class);
SplashScreen.this.startActivity(intent);
SplashScreen.this.finish();
}
}
};
b1.setOnClickListener(l);
ActivityStarter starter = new ActivityStarter();
starter.start();
}
private class ActivityStarter extends Thread {
@Override
public void run() {
try{
Thread.sleep(CZAS);
} catch (Exception e) {
Log.e("SplashScreen". e.getMessage());
}
Intent intent = new Intent(SplashScreen.this, MainActivity.class);
SplashScreen.this.startActivity(intent);
SplashScreen.this.finish();
}
}
}
}