こんにちは、私はアンドロイドの初心者です..メニューウィンドウから Android の登録ウィンドウと呼ばれる別のアクティビティに BMI の計算を表示するにはどうすればよいかを尋ねたいだけです..このコードを実行すると、登録ウィンドウに結果が表示されないためです. 。 ありがとうございました
*登録ウィンドウ *
public void onClick(View v)
{
Intent intent = new Intent(Register.this, Menu.class);
intent.putExtra("response","counter");
startActivity(intent);
int weight = 0, height = 0, age = 0, answer = 0;
String test1, test2, test3;
test1 = getString(R.id.tvWeight);
test2 = getString(R.id.tvAge);
test3 = getString(R.id.tvHeight);
try {
if (test1 != "" && test2 != "" && test3 != "") {
Eweight = (EditText) findViewById(R.id.tvWeight);
weight = Integer.parseInt(Eweight.getText().toString().trim());
Eage = (EditText) findViewById(R.id.tvAge);
age = Integer.parseInt(Eage.getText().toString().trim());
Eheight = (EditText) findViewById(R.id.tvHeight);
height = Integer.parseInt(Eheight.getText().toString().trim());
if(gender.contains("Male"))
answer = (int) Math.round(1.2 * (66 + (13.7 * weight) + (5 * height) - (6.8 * age)));
if(gender.contains("Female"))
answer = (int) Math.round(1.2*(655 + (9.6 * weight) + (1.8 * height) - (4.7 * age)));
response = answer + " kcal/day";
counter.setText(response);
}
} catch (Exception e) {
System.out.println(e);
}
}
メニューウィンドウ
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = getIntent();
intent.getStringExtra("response");
String answer = intent.getStringExtra(response);
}
});