1
我設置了一個onclick方法,我無法訪問我已經在其父方法中設置的int,有沒有不同的方式來使用Int?無法訪問變量onclick方法
這裏是代碼:
Date past = new Date(cYear, cMonth, cDay); // current Date
Date today = new Date(mYear, mMonth, mDay); // date Choosen by the user
int days = Days.daysBetween(new DateTime(past), new DateTime(today)).getDays()+1;
mDateDisplay.setText(""+days);
// display the current date (this method is below)
updateDisplay();
mButton.setOnClickListener(
new View.OnClickListener()
{
public void onClick(View view)
{
s = WorkoutChoice.this.weight.getText().toString();
s2 = WorkoutChoice.this.height.getText().toString();
int w = Integer.parseInt(s);
double h = Double.parseDouble(s2);
double BMI = (w/h)/h;
t.setText(""+BMI);
id = db.insertTitle("001", ""+days, ""+BMI)
}
});
難道是「天」廉政?使其最終:'最後int天= ....' – thaussma 2012-03-31 22:24:10