This question already has an answer here:
- How to call setText() using a Float data type? 1 answer
i tried to call the setText() using the float but it dosnt seem to work can somone help me fix the problem?
public class Bmi extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bmi);
final EditText h = (EditText)findViewById(R.id.editText2);
final EditText w = (EditText)findViewById(R.id.editText3);
final TextView r = (TextView)findViewById(R.id.textView4);
Button calculate = (Button) findViewById(R.id.button1);
calculate.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
float height=0;
float weight=0;
float result=0;
height= Float.parseFloat(h.getText().toString());
weight= Float.parseFloat(w.getText().toString());
result = (weight/(height * height));
r.setText(result);
}
});
}
}
im trying to make a simple bmi calculator just as practice but im having issues on making it work