2016-10-14 99 views
3

我一直在嘗試使用Xamarin.android進行完全自定義通知。
我的項目的目標是min的API 14,所以支持通知。我正在嘗試爲所有API實現相同的外觀,所以我使用的是Android.Support.V4.App.NotificationCompat.Builder使用xamarin.android創建自定義通知

我發現你可以使用setCustomContentView來設置一個自定義的視圖,這將改變通知的佈局,這是我的目標。

這裏是我試圖運行代碼:

RemoteViews widgetLayout = new RemoteViews(PackageName,Resource.Layout.SingleNotificationLayout); 

NotificationCompat.Builder builder = new NotificationCompat.Builder(this) 
       .SetCustomBigContentView(widgetLayout); 

notificationManager.Notify(notificationId, builder.Build()); 

Resource.Layout.SingleNotificationLayout對於notification.Im從MainActiviy。代碼運行此代碼佈局文件從here修改。

,我要面對錯誤是SetCustomBigContentView沒有找到,具體如下:

'NotificationCompat.Builder' does not contain a definition for 'SetCustomBigContentView' and no extension method 'SetCustomBigContentView' accepting a first argument of type 'NotificationCompat.Builder' could be found (are you missing a using directive or an assembly reference?) 

這裏是我安裝的軟件包:

<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.4.0.1" targetFramework="monoandroid70" /> 
<package id="Xamarin.Android.Support.Design" version="23.4.0.1" targetFramework="monoandroid70" /> 
<package id="Xamarin.Android.Support.v14.Preference" version="23.4.0.1" targetFramework="monoandroid70" /> 
<package id="Xamarin.Android.Support.v4" version="23.4.0.1" targetFramework="monoandroid70" /> 
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.4.0.1" targetFramework="monoandroid70" /> 
<package id="Xamarin.Android.Support.v7.GridLayout" version="23.4.0.1" targetFramework="monoandroid70" /> 
<package id="Xamarin.Android.Support.v7.Preference" version="23.4.0.1" targetFramework="monoandroid70" /> 
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.4.0.1" targetFramework="monoandroid70" /> 
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.4.0.1" targetFramework="monoandroid70" /> 

我在想什麼?等效函數名稱不同嗎?

回答

1

您將需要使用支持庫的最新預發佈軟件包。具體https://www.nuget.org/packages/Xamarin.Android.Support.v4/24.2.1-rc1其中包括一個新的程序集:Xamarin.Android.Support.Compat。這將包括你正在尋找的方法:

EX:在DotPeek通過Xamarin.Android.Support.Compat尋找

enter image description here

但是它不包含在當前的穩定(23.4.0.1),你可以看到在這裏:

EX:在DotPeek通過Xamarin.Android.Support.v4尋找

enter image description here