我正在使用带参数的字符串,如下所示:
<string name="share_1">My Android device has reached %1$s points in the app: https://play.google.com/store/apps/details?id=%2$s</string>
String s = getString(R.string.share_1, result.getText().toString(), activity.getApplicationContext().getPackageName());
Lint 给我这个错误:“格式字符串不是有效的格式字符串,因此不应将其传递给 string.format”
我正在使用最新版本的 Android Studio、最新版本的 gradle 和
compileSdkVersion 23
buildToolsVersion "23.0.3"
谢谢
最佳答案
这只是 lint 错误。您可以在 gradle 中禁用 lint 错误
lintOptions {
abortOnError false
}
并且您应该使用 ContextCompat 获取字符串并将其连接起来。
https://stackoverflow.com/questions/39064834/
相关文章:
office365 - outlook.com rest api 不正确的组织者电子邮件
android - 构建android源代码(AOSP)问题
android - Titanium SDK 5.4.0.GA 在 Android 平台的控制台上显
php - 使用 cakephp 2.0 在 sitemap.xml 中显示来自数据库的数据
android - 滚动距离 - 无障碍服务 ACTION_SCROLL_FORWARD?
git - bitbucket - 看不到 merge 分支的提交