Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: cannot convert from String to Editable

Tags:

string

android

A quick question:

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

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

I've also tried casting like following:

Credential.getInstance().UserName = (Editable) preferences.getString("UserName", "invalid value");
Credential.getInstance().Password = (Editable) preferences.getString("UserName", "invalid value");

This time I am getting error : Cannot cast from String to Editable.

What to do?

like image 583
necixy Avatar asked Oct 30 '25 16:10

necixy


1 Answers

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)).

like image 150
Maragues Avatar answered Nov 01 '25 07:11

Maragues



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!