我想在自定义渲染器中创建一个搜索视图,但它总是返回null我尝试了几种不同的方法,但迄今为止相同的结果。现在我已经解决了这个问题,因为它至少不会抛出任何其他错误。SearchView在CustomRenderer中空了
我的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SearchView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mapSearch"
android:layout_marginBottom="0.0dp"
class="Android.Widget.SearchView"/>
<fragment
android:id="@+id/mapWithOverlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px"
class="com.google.android.gms.maps.MapFragment" />
</LinearLayout>
在OnElementChangedMethod
_activity = this.Context as Activity;
_searchView = (SearchView) _activity.FindViewById(Resource.Id.mapSearch);
SetupSearchView();
SetupSearchView方法
public void SetupSearchView()
{
if (_searchView != null)
{
_searchView.QueryTextSubmit += async (sender, e) =>
{
Console.WriteLine(e.Query);
};
}
}
我想你提到上述的作品,那么你的方法不适合你尝试过吗?如果你打包一个小演示,我会看看。我的联系方式在我的个人资料上。 – Pete 2014-10-29 13:46:52
以上,我不工作,我会尝试并获得演示起来,这可能是因为它也是我将如何绑定搜索执行但如果搜索查看为空,这是我在看到这一问题的maprenderer – BillPull 2014-10-29 14:50:52