LuckMan
LuckMan

Reputation: 95

Where is the setting for the suggestion to wrap incompatible argument for TextView's setText() method using the static method String.valueOf()?

Recently I found out that my Android Studio no longer gives the suggestion to wrap an incompatible argument for the TextView's setText() method using the String.valueOf() method.
I sometimes forget to convert the value/variable that I'm going to pass as argument to String, but Android Studio usually gives me a warning AND suggestions to wrap the value/variable, as long as it is possible. Now, for example, when I do this:

double x = 10.567;
textView.setText(double);

Android Studio will still give me a red error warning, but the only suggestion in there is "Cast parameter to 'int'".
enter image description here enter image description here

It used to give me the option to automatically insert the String.valueOf() method call, which is very helpful.

Is it just me or this is how it is now? There was an update a few days ago.
Did I mess up some settings in my Android Studio? Can someone tell me how to fix it? I've looked through the Inspections settings and I haven't found it, if there's even a setting for it.

Upvotes: 0

Views: 78

Answers (1)

Sam Chen
Sam Chen

Reputation: 8857

Maybe the update changes the mechanism, or you can click on the "More actions" in the prompt to see if other options available.

setText() can accept String or int, if you pass in int value, compiler will expect it is String resource ("R.string.xxx"), which is int type. Just memorize this, you don't need to rely on the prompt any more.

Upvotes: 0

Related Questions