我的活动中有一个名为ship1的对象。 ship1有一个名为addSpend的值。 以下
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hangar);
final Ship ship1 = new Ship();
ship1.setAddTime(1000);
ship1.setAddAmount(1);
ship1.setAddSpend(5);
我还有另一个活动,它有一个字符串array.Below
HangarActivity hAObject= new HangarActivity();
int ship1AddSpend = hAObject.ship1.getAddSpend();
final String[] shipDesc = {
"10 Planets Every 5 Secs \n" + ship1AddSpend + "$",
"50 Planets Every 5 Secs \n",
"100 Planets Every 5 Secs \n 1500$",
"500 Planets Every 4 Secs \n 3000$",
"1000 Planets Every 4 Secs \n 7500$",
"5000 Planets Every 4 Secs \n 15000$",
"10000 Planets Every 3 Secs \n 50000$",
"30000 Planets Every 3 Secs \n 100000$",
"60000 Planets Every 3 Secs \n 500000$",
"100000 Planets Every 1 Secs \n 1000000$"};
在第二个活动中,您可以看到我有一个名为ship1AddSpend的整数,它是ship1s addSpend的值。问题是整数不能找到ship1所以在android studio ship1中在第二个活动中出现红色。那么我如何让ship1可以识别第二个活动呢?