This is a migrated thread and some comments may be shown as answers.

List to Java.Lang.Iterable

2 Answers 190 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Saory
Top achievements
Rank 1
Saory asked on 29 Dec 2016, 04:57 PM

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 Answers, 1 is accepted

Sort by
0
Saory
Top achievements
Rank 1
answered on 29 Dec 2016, 05:28 PM
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!
0
Lance | Manager Technical Support
Telerik team
answered on 29 Dec 2016, 09:09 PM
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
Tags
Chart
Asked by
Saory
Top achievements
Rank 1
Answers by
Saory
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or