How to make search functionality in android? [closed]
Hello i am making an small application in which i want search functionality i had done surfing on Internet but i didn't get anything useful. could you give any tutorial or anything so that i can made search functionality in my application.
You should take a very close look to the Search section on Android developper website.
Basically you need to create a Searchable activity in your application by declaring it in the manifest :
<activity android:name="SearchActivity" android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity>
This activity will handle any search request made when the user uses his phone's search button. The search query (what the user typed in the text field) will appear in the intent calling your search activity. You can use it like this in your activity onResume() method :
Intent intent = getIntent();
if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
String query = intent.getStringExtra(SearchManager.QUERY);
// do something with the query...
}
精彩评论