1
0

More than 3 years have passed since last update.

AndroidStudioのtextで文字列を打ち込むとWarningが出る件

Posted at

AndroidStudioでアプリ作成を解説通りやっているときに。。。

textに解説通り文字列を打ち込むとこんなWarning

Hardcoded string "文字列", should use @string resource

解決法

どうやら、文字列をtextに直接打ち込むより@stringを使ったほうがおすすめということらしい

https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1294171037

たとえば、
android:text="テキスト"
とするより、

string,xmlに
テキスト
と定義し、

android:text=@string/text1
とするほうが、コーディングの仕方としておすすめですよ、ということです。

同じ文字列を何度も使うならこの方法は便利かもしれない。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0