2017-03-21 91 views
0

我想在我的應用程序中使用SearchView。我決定使用android.support.v7.widget.SearchView,但在設計器中渲染布局時,xamarin studio會出錯。Xamarin Android:如何在xaml中添加android.support.v7.widget.SearchView

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/lightGray"> 
<TextView 
    android:id="@+id/weatherLocation" 
    android:textStyle="bold" 
    android:textColor="@color/material_grey_600" 
    style="@android:style/TextAppearance.Large" 
    android:layout_marginTop="@dimen/abc_action_bar_subtitle_bottom_margin_material" 
    android:layout_marginBottom="@dimen/abc_action_bar_subtitle_bottom_margin_material" 
    android:layout_marginLeft="@dimen/abc_action_bar_subtitle_bottom_margin_material" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentStart="true" 
    android:text="" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 
<android.support.v7.widget.SearchView 
    style="@style/SearchViewStyle" 
    android:id="@+id/search" 
    android:layout_width="300dp" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@+id/weatherLocation" 
    android:layout_alignEnd="@+id/weatherLocation" 
    android:layout_alignBottom="@+id/weatherLocation" 
    android:layout_alignParentEnd="true" /> 

消息:自定義控件已禁用。渲染過程存在內部問題。

這是否意味着我沒有安裝該軟件包?我在xamarin工作室的nuget上看不到它。

P.S.我可以編譯並運行,但會產生錯誤。

回答

1

您安裝的軟件包應在「已安裝」選項卡中找到。如果你找不到它,是的,這意味着你還沒有安裝這個軟件包。你應該在NuGet上安裝它,搜索'Xamarin.Android.Support.v7.SearchView'並下載它。

+0

現在我已經安裝,但仍然獲得二進制XML文件行#1:錯誤膨脹類android.support.v7.widget.SearchView – LittleFunny

+0

錯誤消息現在正在改變,所以主要問題已修復。你可以嘗試刪除obj/bin文件夾,然後清理並重建你的項目?看看是否可以解決這個問題。 –

+0

現在,如果我使用@ style/Theme.AppCompat.Light將活動更改爲AppCompatActivity,但我不喜歡頂部的ActionBar,它就可以工作。在我調用ActionBar.Hide之前,但在將主題放在 – LittleFunny

相關問題