读书人

Android 搜索UI不显示,该怎么解决

发布时间: 2012-03-23 12:06:21 作者: rapoo

Android 搜索UI不显示
大家好,

我现在使用菜单项调用android搜索框架实现搜索功能,但是在点击搜索时,发现搜索框并没有显示

不知道大家是否碰到过这种问题,现在贴出部分代码:

onSearchRequested()方法代码

public boolean onSearchRequested() {
System.out.println(">>>>>>>>>>>. onSearchRequested is invoke!!");
startSearch("", false, null, false);
return true;
}

Acitivity配置

<activity android:name=".ChatRecordActivity" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<data android:name="android.app.searchable" android:resource="@xml/searchable" />
</intent-filter>
</activity>

searchable配置文件,位置在res/xml目录下面

<?xml version="1.0" encoding="utf-8"?>
<searchable
xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/searchHint"
android:label="@string/searchLable"
android:searchMode="showSearchIconAsBadge"
android:searchSuggestAuthority="szu.mobiledev.SuperMessenger.SearchSuggestionSampleProvider"
android:searchSuggestSelection=" ? ">
</searchable>

[解决办法]

XML code
<meta-data android:name="android.app.searchable"       android:resource="@xml/searchable" /> 

读书人网 >Android

热点推荐