Yashar Ahmedizade Yashar Ahmedizade - 2 years ago 110
Java Question

Making math operations in setText?

Why I'm getting error on this line ?

textView1.setText((editText1.getText() + editText2.getText() + (editText3.getText)) / 3);


Can we do math operations in
setText
method ?

Answer Source

Try this :

float result = (Integer.parseInt(editText1.getText().toString()) +Integer.parseInt(editText2.getText().toString())+Integer.parseInt(editText3.getText().toString()))/ 3;
textView1.setText(""+result );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download