locked
Didn't find class "java.lang.ICharSequence" in AlertDialog.Builder.SetItems() RRS feed

  • Question

  • User44709 posted

    I'm completely ignorant of what's happening here. This is the exception I get:

    Java.Lang.ClassNotFoundException: Didn't find class "java.lang.ICharSequence" on path: DexPathList[[zip file "/data/app/GeorgesMobile.…

    The method where I'm having a problem is here:

        public void SetContracts(IGrowerContractItem[] contracts)
        {
            _controller.SelectedContract = null;
    
            string[] houseNames = contracts.Select(p=>p.ToString()).ToArray();
    
            Button button = FindViewById<Button>(Resource.Id.btnHouse);
            button.Click += new EventHandler((sender, args) =>
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("Pick a house");
                    builder.SetItems(houseNames, new EventHandler<global::Android.Content.DialogClickEventArgs>((innersender, innerargs) =>
                        {
                            _controller.SelectedContract = contracts.Where(p => p.ToString() == houseNames[innerargs.Which]).FirstOrDefault();
    
                        }));
                    AlertDialog ad = builder.Create();
                    ad.Show();
                });
        }
    

    The exception happens on the SetItems() call. It should be able to take an array of strings.

    Tuesday, April 15, 2014 9:12 PM

All replies

  • User209 posted

    What is houseNames?

    Tuesday, April 15, 2014 9:42 PM
  • User44709 posted

    It's defined in the second line of the method.

    Tuesday, April 15, 2014 10:01 PM
  • User209 posted

    Just tried this in a new app:

    Button button = FindViewById<Button>(Resource.Id.MyButton);
    
    var houseNames = new[] {"One", "Two"};
    
    button.Click += delegate
    {
        var builder = new AlertDialog.Builder(this);
        builder.SetTitle("Pick a house");
        builder.SetItems(houseNames, ((innersender, innerargs) =>
        {
            Log.Debug("", houseNames[innerargs.Which]);
        }));
        builder.Show();
    };
    

    Are you sure houseNames is a string array?

    Tuesday, April 15, 2014 10:45 PM
  • User44709 posted
        string[] houseNames = contracts.Select(p=>p.ToString()).ToArray();
    

    Looks like a string array to me. What else might it be?

    Wednesday, April 16, 2014 12:44 PM
  • User44709 posted

    I had breakpoint on exceptions turned on. That's why it was stopping there. Apparently the exception is handled. When I turned off the breakpoint on exceptions it seems to work fine.

    Wednesday, April 16, 2014 1:06 PM