This is a migrated thread and some comments may be shown as answers.

instaceof CalendarDayCell

8 Answers 77 Views
Calendar - Xamarin.Android
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 27 Apr 2015, 03:32 PM

Hi, 

 

I follow the tutorial on the documentation but i have a little problem and i can't solve it ...

 

if (!(calendarCell is CalendarDayCell))
            {
                return;
           }

 

This function always return. I don't understand what does this test mean and why it does not success

 

Hope you can help me ! 

 

Thanks

8 Answers, 1 is accepted

Sort by
0
Antony Jekov
Telerik team
answered on 04 May 2015, 07:24 AM
Hello Jeremy,

Thank you for contacting the Android team!

The cells in year mode are represented by CalendarMonthCell and in month and week mode by CalendarDayCell.

Thank you for your time and all best!

Regards,
Antony Jekov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Jeremy
Top achievements
Rank 1
answered on 04 May 2015, 07:41 AM

Hello Antony, thanks for your reply ! 

 

I am actually in week mode so it shoud be CalendarDayCell right ?

 

Thanks

Jérémy

0
Antony Jekov
Telerik team
answered on 04 May 2015, 11:00 AM
Hello Jeremy,

Yes, and you can check further by using getCellType() to check if the cell is Date, DayName or WeekNumber.

Regards,
Antony Jekov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Jeremy
Top achievements
Rank 1
answered on 04 May 2015, 12:05 PM

Ok, so why it doesn't work ?

 

When i click on a Cell, the test always return false, i don't understand why ..

0
Antony Jekov
Telerik team
answered on 07 May 2015, 11:37 AM
Hello Jeremy,

I confirmed that this code doesn't work indeed. It is supposed to work according to the official documentation of the keywords in the .NET platform - Reference here, but it seems that Mono or Xamarin are behaving differently. I will log this and the examples will be revisited regarding this issue.

Thank you for your feedback!

Regards,
Antony Jekov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Jeremy
Top achievements
Rank 1
answered on 07 May 2015, 03:58 PM

Hi,

 

As same for the  GetFormattedTime function, String doesn't work , you should use string with lowcase, and it's work. 

Like this : 

 

private string GetFormattedTime(string format, long time)
{
Calendar calendar = Calendar.Instance;
calendar.TimeInMillis = time;
DateTime dateTime = new DateTime(
calendar.Get (CalendarField.Year),
calendar.Get (CalendarField.Month) + 1,
calendar.Get (CalendarField.DayOfMonth),
calendar.Get (CalendarField.HourOfDay),
calendar.Get (CalendarField.Minute),
calendar.Get (CalendarField.Second));
return string.Format (format, dateTime);
}

 

Jérémy 

0
Antony Jekov
Telerik team
answered on 12 May 2015, 03:20 PM
Hello Jeremy,

Thank you for your feedback. We will review it at our earliest convenience.

Thank you for your time and all best!

Regards,
Antony Jekov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Trey
Top achievements
Rank 1
answered on 02 Nov 2015, 06:01 PM

I just had this issue resolved today in the event that someone else encounters this problem. This is what I was told to do:

Instead of:


if(!(calendarCell is CalendarDayCell))
{
    return;
}

CalendarDayCell calendarDayCell = (CalendarDayCell) calendarCell;
You need to use:


if (calendarCell.Class.SimpleName == "CalendarMonthCell") {
    return;
}

CalendarDayCell calendarDayCell = calendarCell.JavaCast<CalendarDayCell> ();

 

 

Tags
Calendar - Xamarin.Android
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Antony Jekov
Telerik team
Jeremy
Top achievements
Rank 1
Trey
Top achievements
Rank 1
Share this question
or