operator + cannot be applied to java.lang.charsequence

Kyle Wilko

Trying to make a calculator, here's the button method when the line with the * is ran it comes up with the error "operator + cannot be applied to java.lang.charsequence". If any one know's a way around this 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

foho

In order to convert a charsequence to a String apply .toString() to the CharSequence Object and you should be fine to use + operators:

[https://docs.oracle.com/javase/7/docs/api/java/lang/CharSequence.html][1]

Also it looks like you have a syntax error:

   result.getText() = result.getText() + b.getText()); *** the last ) is too much

Furthermore you cannot write into getText() .. Getters (indicated by getXXX()) should be used to get values while Setters (indicated by setXXX()) should be used to store values into an object.

result.setText(result.getText().toString() + b.getText().toString())

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Operator '<' cannot be applied to 'java.lang.String'

From Dev

Operator == cannot be applied to java.lang.String char

From Dev

operator < cannot be applied to java.lang.String,char

From Dev

The type java.lang.CharSequence cannot be resolved

From Dev

Eclipse Error: java.lang.CharSequence cannot be resolved

From Dev

The type java.lang.CharSequence cannot be resolved in package declaration

From Dev

java.lang.CharSequence cannot be resolved when using drawString

From Dev

cannot be applied to java.lang.double

From Dev

operator cannot be applied to Integer

From Dev

Operator "&&" cannot be applied MVC

From Dev

BasicNameValuePair (String, java.lang.String) in BasicNameValuePair cannot be applied

From Dev

Error when using sendKeys() with Selenium WebDriver Java.lang.CharSequence cannot be resolved

From Java

Operator '+' cannot be applied to Object and String

From Dev

Operator && cannot be applied to 'boolean', 'int

From Dev

Operator '+' cannot be applied to Object and String

From Dev

Operator '+' cannot be applied to Object and String

From Dev

Operator '+' cannot be applied to Object and String

From Dev

Operator '+' cannot be applied to Object and String

From Dev

c# operator ! cannot be applied

From Dev

Operator '==' cannot be applied to operands of type

From Dev

operator || cannot be applied to int and bool

From Dev

Binary operator '+' cannot be applied to two CGFloat operands?

From Dev

binary operator '< ' cannot be applied two T operands

From Dev

Operator '==' cannot be applied to operands of type 'Type?' and 'Type?'

From Java

Binary operator '|' cannot be applied to two UIViewAutoresizing operands

From Dev

Operator '<' cannot be applied to operands of type 'long' and 'ulong'

From Dev

Binary operator ’==’ cannot be applied to two struct operands

From Dev

Operator '?' cannot be applied to operand of type 'T'

From Dev

"Operator '==' cannot be applied to operands of type 'char' and 'string'"

Related Related

  1. 1

    Operator '<' cannot be applied to 'java.lang.String'

  2. 2

    Operator == cannot be applied to java.lang.String char

  3. 3

    operator < cannot be applied to java.lang.String,char

  4. 4

    The type java.lang.CharSequence cannot be resolved

  5. 5

    Eclipse Error: java.lang.CharSequence cannot be resolved

  6. 6

    The type java.lang.CharSequence cannot be resolved in package declaration

  7. 7

    java.lang.CharSequence cannot be resolved when using drawString

  8. 8

    cannot be applied to java.lang.double

  9. 9

    operator cannot be applied to Integer

  10. 10

    Operator "&&" cannot be applied MVC

  11. 11

    BasicNameValuePair (String, java.lang.String) in BasicNameValuePair cannot be applied

  12. 12

    Error when using sendKeys() with Selenium WebDriver Java.lang.CharSequence cannot be resolved

  13. 13

    Operator '+' cannot be applied to Object and String

  14. 14

    Operator && cannot be applied to 'boolean', 'int

  15. 15

    Operator '+' cannot be applied to Object and String

  16. 16

    Operator '+' cannot be applied to Object and String

  17. 17

    Operator '+' cannot be applied to Object and String

  18. 18

    Operator '+' cannot be applied to Object and String

  19. 19

    c# operator ! cannot be applied

  20. 20

    Operator '==' cannot be applied to operands of type

  21. 21

    operator || cannot be applied to int and bool

  22. 22

    Binary operator '+' cannot be applied to two CGFloat operands?

  23. 23

    binary operator '< ' cannot be applied two T operands

  24. 24

    Operator '==' cannot be applied to operands of type 'Type?' and 'Type?'

  25. 25

    Binary operator '|' cannot be applied to two UIViewAutoresizing operands

  26. 26

    Operator '<' cannot be applied to operands of type 'long' and 'ulong'

  27. 27

    Binary operator ’==’ cannot be applied to two struct operands

  28. 28

    Operator '?' cannot be applied to operand of type 'T'

  29. 29

    "Operator '==' cannot be applied to operands of type 'char' and 'string'"

HotTag

Archive