开发者

How to make search functionality in android? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago. 开发者_开发技巧

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... 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜