• We need a new resource directory for xml files.
    • Create a new android resource directory called xml
  • We need a searchable.xml resource file for our search.
    • Note: this can be named a lot of things but for now use the default of searchable.xml.
  • Replace the current element with a searchable element (remember how I replace the PreferenceScreen view?)
  • Add a label and hint attribute to your searchable element.
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
        android:label="@string/app_name"
        android:hint="@string/search_hint" />
  • Open our app manifest
  • Add our <meta-data> about our search as a child of our Activity element inside the manifest.
    • The meta-data contains a name
    • It also contains a resource @xml/link_to link.
  • This tells our activity to be searchable!
<meta-data android:name="android.app.searchable"
            android:resource="@xml/searchable" />
  • While inside our manifest, we should also tell our Activity element that we need to add a new action to our <intent-filter> list.
  • Our action: android.intent.action.SEARCH
<activity android:name=".MainActivity"
            android:launchMode="singleTop">
  <intent-filter>
      <action android:name="android.intent.action.SEARCH" />
  </intent-filter>
...
</activity>

results matching ""

    No results matching ""