レイアウトファイルのactivity_main.xmlで以下のようなハードコードをした場合にAndroidStudioやIDEAで怒られます。
android:text="クリック"
strings.xml
<resources>
<string name="app_name">addApp</string>
<string name="btnName">クリック</string> // 追加
</resources>
strings.xmlに上記のように記述すると、@string/btnName
というような書き方で定義した文字列を取得することができます。
<Button
// android:text="クリック" 削除
android:text="@string/btnName" // 追加
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/btnAdd"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ed2" android:layout_marginTop="8dp"/>
これでワーニングが消えました。