Closed AndriiTsok closed 7 years ago
Are you adding the segments programmatically? First, this control requires Android 4.4 and up.
Yes I am. Our android project configured for 21+
Thats the problem. The control is designed to add the items programmatically. Ummm let me think about it.
Just a snippet.. how I'm trying to wotk with it.
var segmentControl = new SegmentedControl.FormsPlugin.Abstractions.SegmentedControl();
segmentControl.Children.Add(new SegmentedControl.FormsPlugin.Abstractions.SegmentedControlOption() { Text = "ONE" });
segmentControl.Children.Add(new SegmentedControl.FormsPlugin.Abstractions.SegmentedControlOption() { Text = "TWO" });
segmentControl.Children.Add(new SegmentedControl.FormsPlugin.Abstractions.SegmentedControlOption() { Text = "THREE" });
segmentControl.SelectTab(0);
segmentControl.Margin = new Thickness(8, 0);
var segmentedControlContainer = new StackLayout()
{
Orientation = StackOrientation.Vertical,
Children = {
segmentControl
},
Spacing = 0,
Padding = new Thickness(0, 5)
};
Try adding the segments at xaml level.
The thing is that we follow declarative UI implementation in code and don't use Xaml at all. :) It still crashes even if to move adding segment options to the OnAppearing.
One workaround I found is to comment 134-144 and just use two lines 136, 137 instead. PS: Thank you for your quick response to the issue! Appreciate!
I'm going to fix it by checking and comparing types instead of using the index.
I've added pull request for the proposed fix. #12 Would be awesome if you could validate the fix.
Have just tested for both approaches XAML and declaratively. Works fine now. If you create updated NuGet package today I will use the lib. for the production app :) Thank you.
Give me a few min as your fix apply in one more place.
Oh sorry.. these line endings...
Thanks for the fix.
SegmentedControlRenderer throws the exception on SegmentedControlRenderer line 140. Screenshot (debugging): http://prntscr.com/diphc0
From the demo project it works fine.