我有:
Toast.makeText(NewChatActivity.this, getString(R.string.invitation_sent_prompt, contact), Toast.LENGTH_SHORT).show();
(联系人,是一个字符串变量,以及 subForm )和:
new AlertDialog.Builder(NewChatActivity.this).setTitle(getString(R.string.subscriptions))
.setMessage(getString(R.string.subscription_prompt, subFrom))
.setPositiveButton(R.string.approve_subscription, new DialogInterface.OnClickListener() {
....}
在这两个地方,getString
都启动了一个错误:
Format String XXX is not a valid format string so it should be not passed to String.format
该资源如下所示:
<string name="invitation_sent_prompt"> Invitation has been sent to <xliff:g id="user">%1$s</xliff:g>.</string>
.
最糟糕的是,该项目在 Eclipse 上,并且在迁移到 AndroidStudio 后,正在启动此错误。
getString 的问题在哪里?