Gentleman,

I want to try the searchManager and only want to try the customized
searchbar with label and hint. I have reivewed the ApiDemo and
searchManger doc. I do one simple example, but when I press the search
button on device the search bar is still the default "Quick searh box"
but not my customized search bar.

Below is my steps for this example

1. Defined two activity in master xml. One is named "HelloActivity".
One textView and one Button in it. Another one is named
"SearchableActivity". Here is the main codes:
        <activity android:name="HelloActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category
android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity android:name="SearchableActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
                <category
android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                       android:resource="@xml/searchable" />
        </activity>

2. Add searchable.xml into res/xml, main codes here:
<searchable xmlns:android="http://schemas.android.com/apk/res/android";
    android:label="search label"
    android:hint="search hint"
    android:searchMode="showSearchLabelAsBadge"

    android:includeInGlobalSearch="true"
    android:searchSettingsDescription="hello"
/>

3. In HelloActivity, do two things. One is set one string into
textView, the other is bind onClick to Button, when click go to
"SearchableActivity". The onClick code here:
public void onClick(View v) {
                    Intent newIntent = new Intent();
                    newIntent.setClass(HelloActivity.this,
SearchableActivity.class);
                    startActivity(newIntent);

4. In "SearchableActivity" the main code:
        if (Intent.ACTION_SEARCH.equals(queryAction)) {
            mSearchableText.setText("This is searchable activity");
        } else {
            mSearchableText.setText("No search");
        }

I can run it. When on HelloActivity, I invoke the search on device.
The search bar is still default with "Quick search box" but not
"search hint" defined in my searchable.xml. Why? According what I
understand for searchManager, only if add <meta-data
android:name="android.app.searchable"
                       android:resource="@xml/searchable" /> and the
corresponding searchable.xml, when invoke "search" on device, the
search bar should be my defined in searchable.xml, is it right?

Thanks in advanced.

Paul

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to