Android Apidemos Sample resolution: App->search->invoke Search

Source: Internet
Author: User

Search is one of the core features of the Android platform, where users can search for online or local information on their mobile phones. The Android platform provides a unified search framework for all applications that need to provide searching or querying functionality to help achieve search functionality. The UI of the Search framework can have two forms:

Search Dialog at the top of the screen: Google Map, for example.

You can embed the Searchview in Contentview, and the application can place it anywhere on the screen.

Either way, the ui,android system can help the application implement query functionality by sending the content that needs to be queried to a specified activity. At the same time, Android also supports query hints, as shown in the following illustration:

In addition, the Android query UI can support:

Voice query

Provide a list of query hints based on user input

Supports the application of custom query hint lists to match user input

In-system global Search (system-wide Quick search Box) provides a list of your application-related query hints

Invoke search describes how to use the Search Framework and Search dialog to display the query bar at the top of the screen. The following are examples of general steps to use the search framework:

Create a Search Interface

This example uses the search dialog at the top of the screen. In this way, the Android operating system takes over all the search dialog events, and when the user submits the query, the Android system sends messages to the supported activity that is used to process the query. Search dialog can provide a list of query hints to match user input.

After the user submits the query, the Android system constructs a intent and puts the user's query content in the intent. Then Android launches the activity (called the searchable activity) that you defined to handle the user's query, and sends the intent to the activity. To be able to use the search Framework provided by the Android system. The following steps are required:

1. Creating a searchable Configuration

First, you define a searchable configuration that describes the properties of the search Dialog, which are usually named Searchable.xml and defined in the/res/xml directory.

<searchable xmlns:android= "Http://schemas.android.com/apk/res/android"

Android:label= "@string/search_label"

android:hint= "@string/search_hint"

Android:searchmode= "Showsearchlabelasbadge"

Android:voicesearchmode= "Showvoicesearchbutton|launchrecognizer"

Android:voicelanguagemodel= "Free_form"

android:voiceprompttext= "@string/search_invoke"

Android:searchsuggestauthority= "Com.example.android.apis.SuggestionProvider"

Android:searchsuggestselection= "? ”

/>

Only Android:label is required, generally defined as the name of the application. Although not necessary, Android:hint is generally defined. This property defines the background text when the query box does not have any input. As the "Search the dictionary" above. In this case, "Search Demo Hint" to prompt the user to enter the content.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.