2016-12-06 1 views
-3

안녕하세요 여러분, 아래에서 이러한 클래스 중 하나에 많은 공개 문자열이 있습니다.string.xml에 문자열을 추가하는 방법

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

HTTPS에 호출하여 얻을 수 있습니다 : // developer.android.com/guide/topics/resources/string-resource.html 이것을 확인하셨습니까 ?? – Rahil2952

+0

[String Resources] (https://developer.android.com/guide/topics/resources/string-resource.html)주의 깊게 읽어보십시오. 귀하의 질문에 관한 모든 대답을 여기서 찾을 수 있습니다. –

+0

아니, 고맙습니다. Rahil2952 –

답변

0

하면 strings.xml

<string name="HeadlightString">lights not satisfactory</string> 

에 그런 식으로 추가하고 당신은 당신 Activity 또는 Fragment 또는 Context 참조가 다른 클래스

String headlightString = getString(R.string.HeadlightString); 
+0

@ Murat K .. 감사합니다. 이것이 내가 필요한 것입니다. –

관련 문제