我的应用程序中有2个活动,即
Welcome_Activity.java
和
Content_Activity.java
第一个活动工作顺利,但问题出现在
Content_Activity(Second Activity)
从调用
Welcome_Activity(First Activity)
在
onCreate
属于
Second Activity
,我认为内容太多导致活动加载太慢。
例子:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_Puzzle_game);
q1_tv = (TextView) findViewById(R.id.q1_tv);
q2_tv = (TextView) findViewById(R.id.q2_tv);
q3_tv = (TextView) findViewById(R.id.q3_tv);
q4_tv = (TextView) findViewById(R.id.q4_tv);
q5_tv = (TextView) findViewById(R.id.q5_tv);
q6_tv = (TextView) findViewById(R.id.q6_tv);
q7_tv = (TextView) findViewById(R.id.q7_tv);
q8_tv = (TextView) findViewById(R.id.q8_tv);
q9_tv = (TextView) findViewById(R.id.q9_tv);
q10_tv = (TextView) findViewById(R.id.q10_tv);
bt1 = (Button) findViewById(R.id.bt1);
bt2 = (Button) findViewById(R.id.bt2);
bt3 = (Button) findViewById(R.id.bt3);
bt4 = (Button) findViewById(R.id.bt4);
bt5 = (Button) findViewById(R.id.bt5);
bt6 = (Button) findViewById(R.id.bt6);
bt7 = (Button) findViewById(R.id.bt7);
bt8 = (Button) findViewById(R.id.bt8);
bt9 = (Button) findViewById(R.id.bt9);
bt10 = (Button) findViewById(R.id.bt10);
SP = getSharedPreferences("saved_data", MODE_PRIVATE);
solved = SP.getInt("solved", 0);
// LoadLevel & ResumeGame is just a method to get data from another class that have array Strings to fill the textviews and buttons
if (solved > 0) {
ResumeGame(null);
}
else {
LoadLevel(null);
}
}