0
public class SecondScreenActivity extends Activity {
public void OnCreate(Bundle savedInstanceState){
setContentView(R.layout.screen2);
super.onCreate(savedInstanceState);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
TextView counter;
Intent i = getIntent();
String gender = i.getStringExtra("gender");
counter = (TextView) findViewById(R.id.textView23);
int caloriesBurned = 0; int caloriesConsumed = 0;
EditText consumedE;
EditText burnedE;
String test1, test2;
test1 = getString(R.id.txtBurned);
test2 = getString(R.id.txtConsumed);
try {
if (test1 != "" && test2 != "") {
burnedE = (EditText) findViewById(R.id.txtBurned);
caloriesBurned = Integer.parseInt(burnedE.getText().toString().trim());
consumedE = (EditText) findViewById(R.id.txtConsumed);
caloriesConsumed = Integer.parseInt(consumedE.getText().toString().trim());
if(gender.contains("Male") && caloriesConsumed - caloriesBurned > 2000){
counter.setText("You are over your GDA of calories");
}
else{
counter.setText("You're a");
}
}
} catch (Exception e) {
System.out.println(e);
}
}
});
}
我很困惑,因爲我已經離開了一段時間和它交換活動,並可以交換回原來的,不是黑色的屏幕活動它不加載時間。有任何想法嗎? super.onCreate後
getIntent()解析爲什麼? – ucsunil