Error setting TimePicker Hour property on Android

DanielGPDanielGP COMember ✭✭
edited March 2017 in Xamarin.Android

Hi,

I'm trying to set a stored hour to a TimePicker on the OnCreate method.

var _time = dialogView.FindViewById<TimePicker> (Resource.Id.timeDialog_timePicker);

_time.Hour = 8;

On the simulator, it works fine, but on a real device, it shows the following exception:

Java.Lang.NoSuchMethodError: no non-static method "Landroid/widget/TimePicker;.getHour()I"

Any ideas if this is a Xamarin bug?

Testing on a Moto G 1st get. OS Android 5.1

Thank you,

Daniel

Posts

  • GabrielMotaGabrielMota PTMember

    I also have the same problem,any help?

  • DanielGPDanielGP COMember ✭✭

    Hi Gabriel, sorry for the late response, that property is Since API 23, the issue is when you target a lower API, if thats the case you have to use the CurrentHour property

    _time.CurrentHour = (Java.Lang.Integer) 8;

    It works just fine

  • StefanWeidelichStefanWeidelich USMember

    It works for me too. Thank you.

Sign In or Register to comment.