Searchable.xml for Android Studio where?
Where do you add searchable.xml in Android Studio, under layout, values, where? When adding a "new xml file", only layout or values can be used as parameters. Any 2014 code example? Android Studio gives an error for this:
<?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" />
error: element "searchable" does not have a required attribute "http: ....."
Android Studio doesn't seem to recognize " <searchable/>
" as a resource
source to share
Click "Res", "New Android Resource File". File name "searchable.xml", resource type xml, "ok".
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="@string/search_hint" >
</searchable>
In AndroidManifest.xml add the following code inside your app label.
<activity android:name="search.search_class">
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" <---
/>
</activity>
source to share
You need to create xml folder in res folder of your android project and put searchable.xml file in xml
`XML file saved at res/xml/searchable.xml:`
Do it below
<?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" />
In AndroidManifest.xml
<activity android:name=".MainActivity"
android:label="@string/title_activity_main">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable"/> <!-- Your searchable file -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Hope this helps you ...
source to share
Step by step solution:
Step 1: Right click on res> New> Android Resource Directory
Step 2: popup will open Directory name as xml and Resource Type as xml
Step 3: Then the xml
Catalog will be created in the folder res
, right click xml> New> XML resource file
Step 4: a popup will open the set file name as the searchable.xml
Root element assearchable
searchable.xml
your code is generated.
source to share