首页 > 解决方案 > Xamarin Android - 无法访问绑定 Java 库的某些方法?

问题描述

我正在尝试使用通过 Nuget 安装的此 Xamarin 绑定在 Visual Studio 17 中使用Android Java 库CompactCalendarView 。在大多数情况下,函数可以工作,我可以使用设计器添加 CompactCalendarViews。但是,有些方法似乎不存在。我正在尝试在创建的日历视图上使用该方法,但 Visual Studio 给出了 CS1061 错误说明getFirstDayOfCurrentMonth()

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

有问题的代码如下(从此处修改):

        TextView monthAndYear = FindViewById<TextView>(Resource.Id.monthYearDisplay);
        monthAndYear.SetText(dateFormatForMonth.Format(eventCalendarView.GetFirstDayOfCurrentMonth()));

dateFormatForMonth对象在哪里Java.Text.SimpleDateFormat

using对所有三个已定义的包(base、.Domain 和 .Comparators)都有声明,但它不能解决这个问题。

任何和所有的帮助表示赞赏!

标签: androidxamarinandroid-library

解决方案


正如 SushiHangover 所说,Xamarin 将方法调用转换为我能够访问的属性。


推荐阅读