List to Java.Lang.Iterable

3 posts, 0 answers
  1. Saory
    Saory avatar
    2 posts
    Member since:
    Dec 2016

    Posted 29 Dec 2016 Link to this post

    Good evening! I hope you're doing alright!

    I just started working with Telerik for Xamarin android and I'm following the examples we have (This time, the one for RedCartesianChartView). However, it doesn't compile and shows me this error:

    "Cannot implicitly convert type 'System.Collections.Generic.List<AgoraVai.MonthResult>' to 'Java.Lang.IIterable'. An explicit conversion exists (are you missing a cast?"

    The error referes to this line of code:

    lineSeries.Data = (Java.Lang.IIterable)this.monthResults;

     

    I really don't know what to do D: Thank you in advance!

  2. Saory
    Saory avatar
    2 posts
    Member since:
    Dec 2016

    Posted 29 Dec 2016 Link to this post

    SOLVED

    Just after I uploaded the thread I found a solution so I'm uploading it in here in case someone else needs it.
    Instead of using Java.Lang.Iterable, I turned monthResults into an ArrayList first. Then I can set it to my lineSeries.Data.

            LineSeries lineSeries = new LineSeries();
                lineSeries.CategoryBinding = new MonthResultDataBinding("Month");
                lineSeries.ValueBinding = new MonthResultDataBinding("Result");
                Java.Util.ArrayList al = new Java.Util.ArrayList(monthResults);
                lineSeries.Data = al;
                chartView.Series.Add(lineSeries);

    Thanks!
  3. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    457 posts

    Posted 29 Dec 2016 Link to this post

    Hi Saory,

    I'm happy to hear you've resolved the issue.

    I see that you started with the example from this page in the docs. In there, we do cast monthResults to a Java IIterable but we don't show how monthResults was constructed. I can see where this might lead to some confusion if you're using a .NET IEnumerable type for the data source.

    I will inform the Android development team to consider adding a comment about converting the type or maybe expand on the code to see the creation of the list.

    Please let us know if you have any further questions or concerns.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    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
Back to Top