在Android Studio XML文件的“设计”选项卡中找不到字符串资源

时间:2018-05-21 15:44:55

标签: java android string

所以我现在面临的主要问题是Android Studio无法识别我在项目的Strings.xml文件中创建的一些字符串资源。更具体地说,在“设计”选项卡中。

As you can see here, the (highlighted) string is there.

But back in the 'Design' tab, when i go to look for the string, it doesn't recognize that it even exists.

我尝试删除TextView并将其替换为新版本,但遗憾的是没有运气。

是的,我知道我的字符串命名远非最佳。

1 个答案:

答案 0 :(得分:0)

在您的XML文件中,添加所需的字符串

<TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/inspireTxt"
   android:text="@string/inspirational" />

设计师不会总是得到更新。但是,如果你像这样用XML编码,它就会起作用。 其次,如果您仍想使用Designer,请尝试清理和重建项目。 有时新添加的值不会被索引。

希望这有帮助。