我目前正在开发一个应该从启动屏幕过渡到主菜单屏幕的应用程序。我已经完成了编码,但似乎没有这样做。任何人都可以找出下面的代码有什么问题吗?
闪屏活动:
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);
}
}
我的布局已经完成。关于这里有什么问题的任何建议?