I am trying to make a calculator based on the calorie options associated with a food type Spinner (calories stored in array and food class). However it isn't working, any idea what is wrong with this code?
public void onClick(View v, Food cl) {
Spinner spr = (Spinner) findViewById(R.id.planspinner);
EditText editText6 = (EditText) findViewById(R.id.editText6);
TextView textView8 = (TextView) findViewById(R.id.textView8);
String selectedItem = (String) spr.getSelectedItem();
if (selectedItem.trim().equals("*")){
float result = Float.parseFloat(editText6.getText().toString())) * Float.parseFloat(String.valueOf(cl.getCalories()));
textView8.setText(Float.toString(result));
}
Button button4 = (Button) findViewById(R.id.button4);
button4.setOnClickListener(listener);
}
0 comments:
Post a Comment