我想在自定義渲染器中創建一個搜索視圖,但它總是返回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