Skip to content

Android invoke interface method failed #5

@jvhgamer

Description

@jvhgamer

Java.Lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference

Implementation

        public SuperRabbit.Lib.WheelPicker pickerViewModel;
        pickerViewModel = new SuperRabbit.Lib.WheelPicker(Droid.MainActivity._Instance);

        List<object> listDigits = new List<object> {
                "0", "1", "2", "3", "4",
                "5", "6", "7", "8", "9"
        };
        pickerViewModel.SetAdapter(new CustomWheelAdapter(listDigits));

        StackLayout stack = new StackLayout();
        stack.Children.Add(pickerViewModel);
        grid.Children.Add(stack, 0, 0);

        Content = grid;

WheelAdapter class

        public class CustomWheelAdapter : 
            Java.Lang.Object, Android.Support.V7.View.ActionMode.ICallback, SuperRabbit.Lib.IWheelAdapter
        {
            public CustomWheelAdapter(List<object> list)
            {
                ListItems = list;
            }

            public List<object> ListItems { get; set; }

            public int MaxIndex { get; set; }

            public int MinIndex { get; set; }

            public string TextWithMaximumLength { get; set; }

            public int GetPosition(string value)
            {
                return 0;
            }

            public string GetValue(int position)
            {
                return string.Empty;
                //Console.WriteLine("GetValue(); pos:" + position);
                //if (ListItems != null && ListItems.Count >= position)
                //    return ListItems.ElementAt(position).ToString();
                //else
                //    return string.Empty;
            }

            bool Android.Support.V7.View.ActionMode.ICallback.OnActionItemClicked(Android.Support.V7.View.ActionMode mode, IMenuItem item)
            {
                throw new NotImplementedException();
            }

            bool Android.Support.V7.View.ActionMode.ICallback.OnCreateActionMode(Android.Support.V7.View.ActionMode mode, IMenu menu)
            {
                throw new NotImplementedException();
            }

            void Android.Support.V7.View.ActionMode.ICallback.OnDestroyActionMode(Android.Support.V7.View.ActionMode mode)
            {
                throw new NotImplementedException();
            }

            bool Android.Support.V7.View.ActionMode.ICallback.OnPrepareActionMode(Android.Support.V7.View.ActionMode mode, IMenu menu)
            {
                throw new NotImplementedException();
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions