嗨,我有两项活动要参加一项活动。打开活动时,两个活动中的任何一个都会显示一个数字
我需要知道数字的来源,以便进行适当的计算,我想我需要一个 if 语句,但不知道如何开始
Intent intent = new Intent(calculateA.this,
WAmounts.class);
intent.putExtra("Result",Total);
startActivity(intent);
Intent intent = new Intent(CalcB.this,
WAmounts.class);
intent.putExtra("ResultB",Total);
startActivity(intent);
第三次活动
Intent sender = getIntent();
int result = sender.getExtras().getInt("Result");
answer.setText(result+"");
int resultB = sender.getExtras().getInt("ResultB");
answer.setText(resultB+"");
//If number came from first activity
a = Integer.parseInt (answer.getText().toString());
total = (float) (a *x);
sd.setText(String.format("%.1f" ,total));
b = Float.parseFloat (sand.getText().toString());
total1 = (int)Math.ceil (b*f);
c.setText(Integer.toString(total1));
//If number came from second activity
a = Integer.parseInt (answer.getText().toString());
total = (float) (a *x);
sd.setText(String.format("%.1f" ,total));
b = Float.parseFloat (sand.getText().toString());
total1 = (int)Math.ceil (b*f);
c.setText(Integer.toString(total1));