2016-06-24 6 views
2

私のアプリを翻訳しています。したがって、すべてのテキストを文字列にする必要があります。 2つの文字列を除いて、翻訳は正常に機能しました。彼らはちょうど数として示した。私は他のtextviewsで働いていた文字列にはうまくいかなかった文字列を変更しようとしましたが、うまくいきませんでした。なぜ私の文字列が数字として表示されますか?あなたは、文字列の代わりにリソースIDを印刷している文字列が数字として表示されるのはなぜですか?

<string name="repetitions_remaining">Repetitions remaining</string> 

enter image description here

答えて

5

TextView repetitionsRemaining = (TextView)findViewById(R.id.repetitionsRemaining); 
repetitionsRemaining.setText(R.string.repetitions_remaining + ":" + " " 
     + currentRepititions + "/" + repetitionsTotal); 

はここに私のstring.xmlをコードです:

は、ここに私のJavaコードです。これを使用:

TextView repetitionsRemaining = (TextView)findViewById(R.id.repetitionsRemaining); 
repetitionsRemaining.setText(getString(R.string.repetitions_remaining) + ":" + " " + currentRepititions + "/" + repetitionsTotal); 
0

ストリングはリソースとしてstrings.xmlにストリングを格納します。リソースIDを文字列に変換するには、まずString repsRemainingStr = getString(R.string.repetitions_remaining)を呼び出す必要があります。

0

のTextView repetitionsRemaining =(TextViewの)findViewById(R.id.repetitionsRemaining).....これを試してみてください。 "+": "+" + currentRepititions + "/" + repetitionsTotal); を返します。

関連する問題