首先setStartUpScreenText()
从函数内部调用setStartUpWorldValues()
函数(在开头或结尾)。您也可以在函数onCreate()
之后的方法内调用此setStartUpWorldValues()
函数。
其次将函数的整个代码替换为setStartUpScreenText()
以下代码:(第90页,Learn Android App Development,发布者:Apress)
TextView planetNameValue = (TextView) findViewById(R.id.dataView1);
planetNameValue.setText(earth.planetName);
TextView planetMassValue = (TextView) findViewById(R.id.dataView2);
planetMassValue.setText(String.valueOf(earth.planetMass));
TextView planetGravityValue = (TextView) findViewById(R.id.dataView3);
planetGravityValue.setText(String.valueOf(earth.planetGravity));
TextView planetColoniesValue = (TextView) findViewById(R.id.dataView4);
planetColoniesValue.setText(String.valueOf(earth.planetColonies));
TextView planetPopulationValue = (TextView) findViewById(R.id.dataView5);
planetPopulationValue.setText(String.valueOf(earth.planetPopulation));
TextView planetMilitaryValue = (TextView) findViewById(R.id.dataView6);
planetMilitaryValue.setText(String.valueOf(earth.planetMilitary));
TextView planetBaseValue = (TextView) findViewById(R.id.dataView7);
planetBaseValue.setText(String.valueOf(earth.planetBases));
TextView planetForceFieldValue = (TextView) findViewById(R.id.dataView8);
planetForceFieldValue.setText(String.valueOf(earth.planetProtection));