0
我目前正在開發一個應用程序,該應用程序應該從啓動屏幕轉換到主菜單屏幕。我已經完成了編碼,但似乎沒有這樣做。任何人都可以發現下面的代碼有什麼問題嗎?初始屏幕不會轉換到我的主菜單屏幕
閃屏活動:
public class MainActivity extends Activity {
public static final String GAME_PREFERENCES = "GamePrefs";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
// fade in animation
TextView logo1 = (TextView)findViewById(R.id.TextViewTopTitle);
Animation fade1 = AnimationUtils.loadAnimation(this, R.anim.fade_in);
logo1.startAnimation(fade1);
// custom animation
Animation spining = AnimationUtils.loadAnimation(this, R.anim.custom_anim);
LayoutAnimationController controller = new LayoutAnimationController(spining);
TableLayout table = (TableLayout)findViewById(R.id.TableLayout01);
for(int i=0; i < table.getChildCount(); i++)
{
TableRow row = (TableRow) table.getChildAt(i);
row.setLayoutAnimation(controller);
}
startAnimations();
// saving game preferences
SharedPreferences settings = getSharedPreferences(GAME_PREFERENCES, MODE_PRIVATE);
SharedPreferences.Editor prefEditor = settings.edit();
prefEditor.putString("UserName", "JaneDoe");
prefEditor.putInt("UserAge", 22);
prefEditor.commit();
}
private void startAnimations() {
// Transition from Splash screen to Main Menu screen
Animation fade2 = AnimationUtils.loadAnimation(this, R.anim.fade_in2);
fade2.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation)
{
startActivity(new Intent(MainActivity.this,QuizMenuActivity.class));
MainActivity.this.finish();
}
public void onAnimationStart(Animation animation)
{
//Nothing
}
public void onAnimationRepeat(Animation animation)
{
//Nothing
}
});
}
主菜單活動:
public class QuizMenuActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
}
}
我的佈局已經完成。有什麼問題在這裏有什麼建議嗎?
嗯,我可以試試。在啓動畫面上的動畫完成後,我只是打算進入主菜單。 – Neophile
當它在Splash屏幕上卡住時,動畫是否正在播放? –
是的,第一個動畫是在它旋轉並進入窗口前面的時候播放的......不是第二個動畫... – Neophile