Com.Alamkanak.Weekview を使用して、xamarin フォーム Android アプリでカレンダー イベントに取り組んでいます。私の要件は、コンテンツ ページにカレンダー イベントをロードすることです。
そのために、次のようなコンテンツページに ViewRenderer とマイコードを作成しました
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:controls="clr-namespace:App.CustomControls"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:app.CustomControls">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<ContentView>
<OnPlatform x:TypeArguments="View">
<OnPlatform.Android>
<local:CustomCalendarEvent/>
</OnPlatform.Android>
</OnPlatform>
</ContentView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
私のCustomCalendarEventは
public class CustomCalendarEvent : View{ }
私のViewRendererは
[assembly: ExportRenderer(typeof(CustomCalendarEvent), typeof(CustomCalendarEventRenderer))]
namespace App.Droid.CustomRenderers
{
public class CustomCalendarEventRenderer : ViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
{
base.OnElementChanged(e);
if (Control == null)
{
try
{
var intent = new Intent(Forms.Context, typeof(Events));
Forms.Context.StartActivity(intent);
//var context = Xamarin.Forms.Forms.Context;
//LayoutInflater inflater = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;
//var _view = inflater.Inflate(Resource.Layout.EventView, this, false);
//mWeekView = _view.FindViewById<WeekView>(Resource.Id.weekView);
//SetNativeControl(_view);
}
catch (Exception ex)
{
string Message = ex.Message;
}
}
}
}
そして私のイベント活動は
public class Events : AppCompatActivity, WeekView.IEventClickListener, WeekView.IEventLongPressListener, MonthLoader.IMonthChangeListener
{
private SupportToolbar mToolbar;
private static int TYPE_DAY_VIEW = 1;
private static int TYPE_THREE_DAY_VIEW = 2;
private static int TYPE_WEEK_VIEW = 3;
private int mWeekViewType = TYPE_THREE_DAY_VIEW;
private WeekView mWeekView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.EventView);
---
----------
---
----------
---
----------
}
}
StartActivity を使用している場合、イベント ページが別のページとして表示され、SetNativeControl(_view) を使用している場合、イベントがコンテンツ ページに表示されません。ViewRenderer を使用して、コンテンツ ページでイベント アクティビティを読み込む方法を教えてください。
ありがとう。