我得到了三个活动导致相同的活动,其中显示了一个数字,并根据它的来源进行了一些计算,当我在每个意图中只有一个额外的时候,一切都很好,但是让我们说活动一个我需要知道什么选项被选中了,所以我又添加了三个额外的。
但是我在活动一中添加的这三个额外的在上一个活动中似乎没有被识别。
活动一
if (selectedItem.trim().equals("100mm")) {
Total1 = (int) (a * b * 10);
}
else if (selectedItem.trim().equals("215mm")) {
Total2 = (int) (a * b * 20);
}
else if (selectedItem.trim().equals("325")) {
Total3 = (int) (a * b * 30);
}
else if (selectedItem.trim().equals("hollow ")) {
Total4 = (int) (a * b * 10);
}
Intent intent = new Intent(CalculateB.this,
WlAmounts.class);
intent.putExtra("Result100",Total1);
intent.putExtra("Result215", Total2);
intent.putExtra("Result325", Total3);
intent.putExtra("ResultHollow",Total4);
startActivity(intent);
上次活动
Intent sender = getIntent();
int edge = sender.getExtras().getInt("Result100");
int flat = sender.getExtras().getInt("Result215");
int wide = sender.getExtras().getInt("Result325");
int hollow = sender.getExtras().getInt("ResultHollow");
int opes1 = sender.getExtras().getInt("ResultOpe1");
int opes2 = sender.getExtras().getInt("ResultOpe2");
if (getIntent().hasExtra("Result100")) {
answer.setText(edge + "");
} else if (getIntent().hasExtra("Result215")) {
answer.setText(flat + "");
//i'm doing some calculations here
} else if (getIntent().hasExtra("Result325")) {
answer.setText(wide + "");
//i'm doing some calculations here
} else if (getIntent().hasExtra("ResultHollow")) {
answer.setText(hollow + "");
//i'm doing some calculations here
} else if (getIntent().hasExtra("ResultOpe1")) {
answer.setText(opes1 + "");
//i'm doing some calculations here
} else if (getIntent().hasExtra("ResultOpe2")) {
answer.setText(opes2 + "");