【问题标题】:Updated to Android Studio 2.1.2, now string formatting doesn't work更新到 Android Studio 2.1.2,现在字符串格式不起作用
【发布时间】:2016-06-25 03:51:25
【问题描述】:

我目前正在 Android Studio 中开发一个简单的应用程序。

我最近从 Android Studios 1.5 更新到 2.1.2,不知何故,这个更新弄乱了字符串格式。现在,我所有的 getString 调用都不起作用了。

这是我要调用的线路:

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

这是错误:

“格式字符串“SpeedView”不是有效的字符串格式,因此不应将其传递到 String.format。”

这是字符串资源 SpeedView:

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

我在这里遗漏了什么明显的东西吗?

【问题讨论】:

    标签: android string


    【解决方案1】:

    你应该试试

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-20
      • 2017-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多