Answer the question
In order to leave comments, you need to log in
Why is parseFloat not working properly?
Why is this code not working properly? parseFloat when getting a number from EditText.getText().toString() gives me 0.0 , although if I put just a string (for example, 1.1), everything works fine.
Non-working code:
EditText et = (EditText) findViewById(R.id.EditText1);
String b = et.getText().toString();
float a = Float.parseFloat(b);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TextView text = findViewById(R.id.textView4);
text.setText(String.valueOf(String.valueOf(a)));
}
});
float a = Float.parseFloat("1.1");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question