2017-02-27 59 views
-1

解析字符串我指定的字符串值在String.xml的Android:錯誤從string.xml

<string name="complaint_fragment_type_label">Type</string> 

,並在佈局文件

<TextView 
      android:id="@+id/textView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:maxLines="1" 
      android:text="@string/complaint_fragment_type_label" 
      android:textSize="17sp" 
      android:textStyle="bold" /> 

,但我有在收到錯誤TextView中的字符串「Type」。什麼可能是在textview中獲取字符串的解決方案?

+2

'但我有在獲取字符串「類型」的錯誤TextView中。 「什麼是錯誤?! –

+0

你的代碼沒有錯誤..你得到了什麼錯誤 – sravs

+0

顯示logcat – tahsinRupam

回答

0

問題是因爲s​​tring.xml不是值資源文件。您可以通過右鍵單擊值目錄然後選擇新的值來創建值資源文件,您將獲得選項。然後,只需將其命名爲並給予<resources>標籤內<string>標籤和你在做

0
<TextView 
      android:id="@+id/textView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:maxLines="1" 
      android:text="Complaint" 
      android:textSize="17sp" 
      android:textStyle="bold" /> 

嘗試......