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 { ...
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>
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.
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
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 {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With