button - operator + cannot be applied to java.lang.charsequence -
trying create calculator, here's button method when line * ran comes error "operator + cannot applied java.lang.charsequence". if 1 know's way around please help.
public void button_click(view view) { textview result = (textview) findviewbyid(r.id.result); button b = (button)view; if ((result.gettext() == "0")||(operation_pressed)) result.settext(""); operation_pressed = false; if (b.gettext() == ".") { result.gettext() = result.gettext() + b.gettext()); *** } }
thanks
in order convert charsequence string apply .tostring() charsequence object , should fine utilize + operators:
[https://docs.oracle.com/javase/7/docs/api/java/lang/charsequence.html][1]
also looks have syntax error:
result.gettext() = result.gettext() + b.gettext()); *** lastly ) much
furthermore cannot write gettext() .. getters (indicated getxxx()) should used values while setters (indicated setxxx()) should used store values object.
result.settext(result.gettext().tostring() + b.gettext().tostring())
button operators charsequence
No comments:
Post a Comment