The Clueless Programmer The Clueless Programmer - 5 months ago 16
Android Question

Updated to Android Studio 2.1.2, now string formatting doesn't work

I am currently developing a simple app in Android Studio.

I have recently updated from Android Studios 1.5 to 2.1.2, and somehow this update messed something up with string formatting. Now, all my getString calls aren't working.

This is the line I'm trying to call:

String SpeedDisplayText = getString(R.string.SpeedView, Speed);


This is the error:

"Format string "SpeedView" is not a valid string format so it should not be passed into String.format."

And this is the string resource SpeedView:

<string name= "SpeedView">Your current speed is </string>


Am I missing something obvious here?

Answer

you should try

 <string name= "SpeedView">Your current speed is %s</string>
Comments