Can't get the NumberPickers from TimePicker - Android version 7.0 (API 24)

AlonromAlonrom Member ✭✭
edited October 2018 in Xamarin.Android

Hi,

I have an Android.Widget.NumberPicker in my app and I'm using a FindAllChildernByType method to get the NumberPickers inside.
It seems that the NumberPicker is different on Android version 7.0 (API 24). There is no NumberPickers, only TexViews, so when running on this OS, the app crashes.

Is it a known issue? Thus anyone came up with a nice solution for this?

Best Answer

Answers

  • AlonromAlonrom Member ✭✭
    edited October 2018
    TreeHelper.FindAllChildernByType<NumberPicker>(_timePicker).ToList();
    
    public static IEnumerable<T> FindAllChildernByType<T>(ViewGroup viewGroup) where T : View
     {
    
            for (var i = 0; i < viewGroup.ChildCount; i++)
            {
                var child = viewGroup.GetChildAt(i);
                if (child != null && child is T)
                {
    
                    yield return (T)child;
    
                }
    
                var childViewGroup = child as ViewGroup;
                if (childViewGroup != null)
                {
                    foreach (T childOfChild in FindAllChildernByType<T>(childViewGroup))
                    {
                        yield return childOfChild;
                    }
                }
            }
        }
    
  • HI All,
    the posted solution, unfortunately, does not work, I'm using forms v. 4.0.0497661, deploying to android 6.0.1. My goal is to change the minute picker interval to 15 mins (and stay still in clock mode), and it seems that there's no access to the MinutePicker from TimePicker or TimePicker dialog (via CustomRenderer),

    I will have to debug the source code, if not then...implement completely new control as I cannot get easy the Numberpicker( Android.Widget) to clock mode.

    Any suggestions appreciated.

    Regards,
    Tomasz

Sign In or Register to comment.