Android: cannot convert from String to Editable

后端 未结 2 461
长发绾君心
长发绾君心 2021-01-21 00:14

A quick question:

I am getting the error : cannot convert from String to Editable. Here is the code :

Credential.getInstance().UserName = preferences.get         


        
相关标签:
2条回答
  • 2021-01-21 00:42

    For anyone interested in converting a String to Editable

    Editable.Factory.getInstance().newEditable("myString");
    

    From the docs, append is

    Convenience for append(String.valueOf(text)).

    0 讨论(0)
  • 2021-01-21 00:48

    Surely:

    Credential.getInstance().UserName.append(preferences.getString("UserName", "invalid value"));
    

    The API with the answers:

    http://developer.android.com/reference/android/text/Editable.html

    0 讨论(0)
提交回复
热议问题