Adding metadata to activity in xamarin.android

How to add metadata for searching xml to Activity using attributes in Xamarain.Android. Metadata to be added: -

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

      

Here I am doing a search list view by android using the ActionBar Search Widget in Xamarin.Android. any help is appreciated. :)

+3


source to share


2 answers


There is a MetaDataAttribute that you can add to your activity.



[Activity]
[MetaData("android.app.searchable", Resource="@xml/searchable")]
public class MyActivity : Activity
{
}

      

+2


source


You probably need to add both IntentFilterAttribute and MetaDataAttribute

The following solution works great for me:

[Activity (...)]
[IntentFilter(new[]{Intent.ActionSearch})]
[MetaData("android.app.searchable", Resource="@xml/searchable")]

public class MainActivity : Activity
{

      



...}

A good explanation on how to add a search function can be found here: http://codetheory.in/adding-search-to-android/

0


source







All Articles