搜索对话框中的单声道的Andr​​oid [英] Search Dialog in Mono Android

查看:117
本文介绍了搜索对话框中的单声道的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现每这里的文档中的单声道Android应用程序搜索对话框: <一href="http://developer.android.com/guide/topics/search/search-dialog.html">http://developer.android.com/guide/topics/search/search-dialog.html

I'm trying to implement a search dialog in a Mono Android app per the documentation here: http://developer.android.com/guide/topics/search/search-dialog.html

我有,用户应该能够从搜索活动:

I have an activity that the user should be able to search from:

[Activity (Label = "MyActivity", MainLauncher = true, Icon = "@drawable/icon", Theme = "@style/MyStyle")]
[MetaData ("android.app.default_searchable", Value = ".SearchActivity")]
public class MainActivity : BaseActivity {...

我有一个可搜索的活动(其中重型起重会发生):

I have a searchable activity (where the heavy-lifting will happen):

[Activity(Theme = "@style/MyStyle", Label = "Searchable", LaunchMode = Android.Content.PM.LaunchMode.SingleTop)]
[IntentFilter(new[] { Intent.ActionMain }, Categories = new[] { Intent.CategoryLauncher, Intent.ActionSearch })]
[MetaData("searchable", Resource = "@xml/searchable")]
public class SearchActivity : BaseActivity { ...

和我有我的searchable.xml:

And I have my searchable.xml:

<?xml version="1.0" encoding="utf-8"?>
<searchable
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:label="MyLabel"
  android:hint="Search Products">
</searchable>

当我preSS在MainActivity手机上的搜索键,没有任何反应 - 没有任何对话框。我想我的问题在于如何属性正在被翻译成AndroidManifest.xml中运行时,但我不知道。

When I press the search key on the phone in the MainActivity, nothing happens - no dialog. I think my problem lies with how the attributes are being translated into the AndroidManifest.xml at runtime but I'm not sure.

更新2012/1/3: 我已经发布蒸馏水到这里的最基本元素的一个项目。 preSS您的Andr​​oid和你的搜索按钮应该看到SearchDialog,但它并没有出现:示范项目在这里

UPDATE 1/3/2012: I have posted a project distilled down to the most basic elements here. Press the search button on your Android and you should see the SearchDialog but it doesn't appear: Demo Project Here

推荐答案

现在的问题是在 MainActivity [元数据] 属性C $ C>。如果您提供的类的命名空间的正确版本的搜索对话框显示正确:

The problem is in the [MetaData] attribute on MainActivity. If you provide the properly namespaced version of the class the search dialog appears correctly:

[MetaData ("android.app.default_searchable", Value = "searchdialogtest.SearchActivity")]
public class MainActivity : BaseActivity {

这篇关于搜索对话框中的单声道的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆