Reputation: 560
I'm currently developing an app, and have run into an issue causing it to force-close on me whenever I try to call this function:
public void calcActRun() {
double calcmass = bodymass * genderValue;
int qty1 = Integer.parseInt(findViewById(R.id.calcItemQty1).toString());
double vol1 = Double.parseDouble(findViewById(R.id.calcItemVol1).toString());
double percent1 = Double.parseDouble(findViewById(R.id.calcItemQty1).toString());
double alcoholTotal = 0;
double alcoholConcentration = alcoholTotal /calcmass;
int time = Integer.parseInt(findViewById(R.id.calcInputTime).toString());
double alcoholCurrentConcentration = alcoholConcentration - (0.15 * time);
}
}
I have defined all variables (except the ones defined inside this function) earlier in the code, and eclipse isn't giving me any hints as to why it crashes...
The goal is to input the various values in a form (as you may already have guessed from the code) and get the calculated output when a button in the UI is clicked.
I even tried calling it using a "man in the middle", with the same result (code displayed below)
public void calcButtonClicked(View v) {
calcActRun();
}
I know the button itself is working, as everything went ok when I replaced the contents with this:
Toast.makeText(this, "test", Toast.LENGTH_SHORT).show();
I would be really grateful if anyone could help me demystify this problem - also if you need more info just ask... :)
Upvotes: 0
Views: 183
Reputation: 1368
I think you want
((TextView)findViewById(R.id.whatever)).getText().toString()
instead of
findViewById(R.id.whatever).toString()
Upvotes: 7