2017-02-27 1 views
-1

から文字列を解析中にエラーが発生しました私はstring.xmlをアンドロイド: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"。テキストビューで文字列を取得する解決策は何ですか?

+2

'しかし、私は、文字列「タイプ」を得ることにエラーが発生しています... –

+0

あなたのコードにエラーはありません。あなたが得ているエラーは – sravs

+0

logcatを表示 – tahsinRupam

答えて

0

問題は、string.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" /> 

これを試してみてください

を行っていますTextView。 `エラーは何ですか?
関連する問題