안드로이드
R.string.xxx String 값 얻어오기.
블루건
2016. 3. 9. 16:11
Resource ID 말고 실제의 string값을 얻기 위한 함수 getString(resId)
http://developer.android.com/intl/ko/guide/topics/resources/string-resource.html 참조
res/values/strings.xml
:<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
</resources>
This layout XML applies a string to a View:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
This application code retrieves a string:
String string = getString
(R.string.hello);
You can use either getString(int)
or getText(int)
to retrieve a string. getText(int)
will retain any rich text styling applied to the string.