Android 搜索 Activity 和 android :launchMode ="singleTop"

标签 android searchview android-searchmanager android-search

我的应用程序中有一个使用 SearchView 进行搜索的 Activity (请参阅 list ——搜索 Intent 被拦截)。 但是,当我按搜索时,没有任何反应。该 Activity 永远不会重新开始。所以,我从我的 Activity 中删除了 android:launchMode="singleTop"然后它开始重新启动并“工作”。但是,我最好使用 singleTop,这样 Activity 只有一个实例。为什么当我有 singleTop 时这不起作用?

<activity
        android:name="com.brianco.andypedia.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTop" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>
        <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
    </activity>

    <meta-data android:name="android.app.default_searchable"
        android:value=".MainActivity" />

最佳答案

我不知道这是否回答了您的问题,但是 this page展示了一个带有 ActionBar Compat 的简单搜索 View 示例(它是与旧 Android 版本兼容的新谷歌库)

关于Android 搜索 Activity 和 android :launchMode ="singleTop",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19337863/

相关文章:

android - 如何在可搜索微调器中使用 SearchView.OnQueryTextListener()?

android - 使用 Android 工具栏更改 SearchView 中的 TextColor

java - 单击返回时在 SearchView 中重置搜索

android - 如果用户按下设备的搜索按钮,则在 ActionBar 中显示 SearchWidget

android - MediaRecorder 准备失败

android - 删除索引无法正常工作的SQlite Android

android - 有没有办法从 Google Play 上的开发者那里获取所有应用程序

android - 仅限手机(iPhone 和 Android)的 css

android - 在 SearchView 中键入时带有文本的奇怪灰色弹出窗口

java - 机器人 : adding SearchView inside a Custom ListView with Custom Adapter