Karamunting.Android.ArchitShah248.CalendarDateRangePicker 1.0.1

NuGet\Install-Package Karamunting.Android.ArchitShah248.CalendarDateRangePicker -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Karamunting.Android.ArchitShah248.CalendarDateRangePicker --version 1.0.1
<PackageReference Include="Karamunting.Android.ArchitShah248.CalendarDateRangePicker" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Karamunting.Android.ArchitShah248.CalendarDateRangePicker --version 1.0.1
#r "nuget: Karamunting.Android.ArchitShah248.CalendarDateRangePicker, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Karamunting.Android.ArchitShah248.CalendarDateRangePicker as a Cake Addin
#addin nuget:?package=Karamunting.Android.ArchitShah248.CalendarDateRangePicker&version=1.0.1

// Install Karamunting.Android.ArchitShah248.CalendarDateRangePicker as a Cake Tool
#tool nuget:?package=Karamunting.Android.ArchitShah248.CalendarDateRangePicker&version=1.0.1

Sample Usage

// Created by Rofiq Setiawan (rofiqsetiawan@gmail.com)

using System;
using Android.App;
using Android.Graphics;
using Android.OS;
using Android.Support.V7.App;
using Android.Util;
using Android.Widget;
using Com.Archit.CalendarDateRangePicker.CustomViews;
using R = CalendarDateRangePickerDemo.Resource;

namespace CalendarDateRangePickerDemo
{
    [Activity(Label = "@string/app_name", MainLauncher = true)]
    public sealed class MainActivity : AppCompatActivity
    {
        private const string MyTag = "CalendarDateRangePickerDemo";

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(R.Layout.activity_main);

            var typeface1 = Typeface.CreateFromAsset(Assets, "JosefinSans-Regular.ttf");
            var typeface2 = Typeface.CreateFromAsset(Assets, "LobsterTwo-Regular.ttf");

            var calendar = FindViewById<DateRangeCalendarView>(R.Id.calendar);
            calendar.SetFonts(typeface1);
        }

        private void ToastMe(string message)
        {
            if (string.IsNullOrEmpty(message)) return;

            Toast.MakeText(this, message, ToastLength.Short).Show();
        }
    }
}

Listen to Calendar's Change

With Listener

// With Listener
calendar.SetCalendarListener(
    new DateRangeCalendarView.CalendarListener(
        onDateRangeSelectedAction: (DateTime startDate, DateTime endDate) =>
        {
            var msg = $"OnDateRangeSelectedAction: from {startDate.ToString("yyyyMMdd")} to {endDate.ToString("yyyyMMdd")}";
            Log.Debug(MyTag, msg);
            ToastMe(msg);
        },
        onCancelAction: () =>
        {
            const string msg = "OnCancelAction";
            Log.Debug(MyTag, msg);
            ToastMe(msg);
        }
    )
);

With EventHandler

// With EventHandler
calendar.DateRangeSelected += (s, e) =>
{
    var msg = $"DateRangeSelectedEventHandler: from {e.StartDate:yyyyMMdd} to {e.EndDate:yyyyMMdd}";
    Log.Debug(MyTag, msg);
    ToastMe(msg);
};
calendar.CancelSelection += (s, e) =>
{
    const string msg = "CancelSelectionEventHandler";
    Log.Debug(MyTag, msg);
    ToastMe(msg);
};
Product Versions
MonoAndroid monoandroid71
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 919 5/13/2018