Android 中從res/values/strings.xml中讀取具體的字串的方法
阿新 • • 發佈:2019-02-04
正確的解法:
String mess = getResources().getString(R.string.mess_1);
另外一種:
you can simplify that to
this.getString(R.string.some_id)
關鍵點android 字串比較,android 擷取字串,android 字串,android 字串陣列,androidpost字串,android 字串轉換,
字串資源的定義
檔案路徑:res/values/strings.xml
字串資源定義示例:
字串資源的呼叫
在 Layout XML 呼叫字串資源:
<TextViewandroid:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"/>
在 Activity 獲取字串資源:
從 Context 獲取字串資源:
從 Application 獲取字串資源: