Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
These resources are available to Java (http://stackoverflow.com/a/21291092) but not to C#. As a result, when using android.support.v7.widget.SearchView, I am forced to do this:
// obtain the id by inspecting the visual tree of the search view in the debugger
int searchPlateId = 2131427382;
View searchPlate = searchView.FindViewById(searchPlateId);
I am sure there's no need to explain why this is a horrible "solution". I am aware of this approach:
int searchPlateId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);
but for some reason it only returns a correct id for the regular (non-support) SearchView.
I am going to try some Java reflection in order to get to android.support.v7.appcompat.R.id.search_plate but even if I make it it will still be ugly so the issue remains.
The following code:
var id = Class.ForName("android.support.v7.appcompat.R$id");
int searchPlateId = (int) id.GetField("search_plate").Get(id);
int searchSrcTextId = (int) id.GetField("search_src_text").Get(id);
works. As you know, Class.getField only retrieves public fields (unlike getDeclaredField) which is further proof that the class should be accessible through C#.
Xamarin.Android 4.x includes an ancient version of the Android support library. Xamarin.Android 5.0 no longer includes the binding; you should instead use the Android Support Component:
The component doesn't appear to provide that member either. Let's see if they have any ideas...
The component includes the SearchView class since version 188.8.131.52