大家好我在我的一个课程中有很多公共字符串,如下所示。
public String HeadlightString = "lights not satisfactory",
ReflectorString = "Reflectors and warning devices not satisfactory",
HornString = "Horn and other warnings not satisfactory",
MirrorsString = "Mirrors not satisfactory",
BrakessystemStrings = "Problem with the brakes System";
如何将它们添加到我的string.xml然后将它们调用到我的类。这真的有助于整理我的代码。
答案 0 :(得分:0)
将这些内容添加到strings.xml
<string name="HeadlightString">lights not satisfactory</string>
然后,您可以通过致电Activity
或Fragment
或任何其他具有Context
参考的课程来获取
String headlightString = getString(R.string.HeadlightString);