0
我遇到了微調問題,它沒有顯示任何內容,並且出現錯誤。請在下面檢查代碼:Android微調值無法顯示答案
private void createSpinnerValues(){
spinnerValues = new HashMap<String, Double>();
spinnerValues.put("Sedentary", 1.2);
spinnerValues.put("Lightly Active", 1.375);
spinnerValues.put("Moderately Active", 1.55);
spinnerValues.put("Heavily Active", 1.725);
} // end of createSpinnerValue
private Double getAnswer(String age, String in, String ft, String weight, Double selectedItemValueFromSpinner) {
double answer = ((66 + (6.2377 * Double.parseDouble(weight)) +
(12.7084 * (Double.parseDouble(in) * 12 + Double.parseDouble(ft)))
- (6.8 * Double.parseDouble(age))) * selectedItemValueFromSpinner);
return answer;
} // end of getAnswer method
private Double getSelectedItemValueFromSpinnerText(String spinnerText) {
Double val = spinnerValues.get( spinnerText);
if(val==null){
Log.i("DEMO", "Value is null"); }
return val;
}
private void calculateWomen(){
String f1a = etft.getText().toString();
String f2a = etin.getText().toString();
String f3a = etweight.getText().toString();
String f4a = etage.getText().toString();
if ((f1a.isEmpty() || f2a.isEmpty() || f3a.isEmpty() || f4a.isEmpty()))
// call for custom toast
viewErrorToast();
else{
// Metric Formula for BMR (Women) English Unit
//655 + (4.3379 x weight in pounds) +
//(4.6980 x height in inches) - (4.6756 x age in years)
String age, in, ft, weight;
Double answer;
age = etage.getText().toString();
in = etin.getText().toString();
ft = etft.getText().toString();
weight = etweight.getText().toString();
answer = ((665 + (4.3379 * Double.parseDouble(weight)) +
(4.6980 * (Double.parseDouble(in)) * 12 + Double.parseDouble(ft))
- (4.6756 * Double.parseDouble(age))) * 1.2);
BigDecimal bd = BigDecimal.valueOf(answer);
bd = bd.setScale(2, BigDecimal.ROUND_FLOOR);
etanswer.setText(bd.toString());
// call for custom toast
viewBMRSavedToast();
}
} // end of calculateWomen method
請幫我找出我的問題,我是新來的Android編程。任何幫助,將不勝感激。謝謝
它沒有顯示任何東西,我得到一個錯誤...如果你仍然有t請給我們提供錯誤他的問題 – Araw