Я новичок в разработке Android и сейчас создаю простой калькулятор для работников здравоохранения. Моя программа реализует класс OnClickListener, но каждый раз, когда я нажимаю на кнопку, чтобы начать вычисление, я получаю сообщение об ошибке «Источник не найден».
Вот код:
public class KidneyeGFR extends Activity implements OnClickListener {
TextView EditAge;
TextView EditSerum;
TextView Gfrtext;
RadioButton Male;
RadioButton Female;
RadioButton EveryoneElse;
RadioButton African;
Button Calculate;
double gender;
double race;
double finalgfr;
private static final int GFRCONST = 186;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
EditAge = (TextView)this.findViewById(R.id.EditAge);
EditSerum = (TextView)this.findViewById(R.id.EditSerum);
Male = (RadioButton)this.findViewById(R.id.Male);
Male.setChecked(true);
Female = (RadioButton)this.findViewById(R.id.Female);
EveryoneElse = (RadioButton)this.findViewById(R.id.EveryoneElse);
EveryoneElse.setChecked(true);
African = (RadioButton)this.findViewById(R.id.African);
Calculate = (Button)this.findViewById(R.id.Calculate);
Calculate.setOnClickListener(this);
}
public void onClick(View v) {
if (Female.isChecked()) {
gender = 0.742;
}
else {
gender = 1.0;
}
if (African.isChecked()) {
race = 1.212;
}
else {
race = 1.0;
}
calculateGFR();
}
protected void calculateGFR() {
int age = Integer.parseInt(EditAge.getText().toString());
double serum = Double.parseDouble(EditSerum.getText().toString());
finalgfr = GFRCONST * Math.pow(serum, -1.154) * Math.pow(age, -0.203) * gender * race;
Gfrtext.setText(Double.toString(finalgfr));
}