开发者

Android search dialog doesn't appear

开发者 https://www.devze.com 2023-03-03 13:32 出处:网络
Hello i am frustrated with the search dialog like presented on http://developer.android.com/guide/topics/search/search-dialog.html

Hello i am frustrated with the search dialog like presented on http://developer.android.com/guide/topics/search/search-dialog.html

No search dialog is shown to me when i press the search button on my device. here is my simple manifest file:

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".Main"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <meta-data android:name="android.app.default_searchable"
            android:value=".Other" />
    </activity>
    <activity android:name=".Other">
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>
        <meta-data android:name="android.app.searchable"
            android:resource="@xml/searchable"/>
    </activity>
</application>

My res/xml/searchable.xml looks like this:

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
   android:label="lol"
   and开发者_运维问答roid:hint="search" >
</searchable>

in Main.java onSearchRequested() is triggered but no search dialog appears.

am i missing something?


To remove the question from not answered, copying the comment with the solution:

oh my god. this is f*ing stupid. i had to use android:label="@string/xyz" instead of android:label="lol" and no single word about this in the documentation. unbelievable


"The android:label attribute is the only required attribute. It points to a string resource, which should be the application name. This label isn't actually visible to the user until you enable search suggestions for Quick Search Box. At that point, this label is visible in the list of Searchable items in the system Settings."

0

精彩评论

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

关注公众号