i++

プログラム系のメモ書きなど

Android : SearchView の hint が表示されない

searchable.xmlandroid:hint に直接文字列をハードコーディングすると、SearchView が空の時に表示されるはずのヒントテキストが表示されません。

@string/search_hint などの String リソースを定義して、それを参照する必要があります。

OK

<searchable
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:label="@string/app_name"
  android:hint="@string/search_hint"
  android:voiceSearchMode="showVoiceSearchButton|launchRecognizer">
</searchable>

NG

<searchable
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:label="@string/app_name"
  android:hint="Search Hint"
  android:voiceSearchMode="showVoiceSearchButton|launchRecognizer">
</searchable>