Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help Needed #11

Open
primehalo opened this issue Jun 7, 2018 · 1 comment
Open

Help Needed #11

primehalo opened this issue Jun 7, 2018 · 1 comment

Comments

@primehalo
Copy link

I'm trying to integrate this into my project, specifically the HorizontalViewNative, but I can't get anything to show up inside the <local:HorizontalViewNative>. I added a bunch of debug statements and it seems like the RecycleViewAdapter is never being set in AndroidHorizontalViewRenderer.cs's OnElementPropertyChanged() because e.PropertyName is never "ItemsSource". I'd really appreciate any insight you might have.

@primehalo
Copy link
Author

primehalo commented Jun 7, 2018

Okay, so adding

var adapter = new RecycleViewAdapter(Element);
Control.SetAdapter(adapter);

after SetNativeControl(recyclerView); inside OnElementChanged() seems to have gotten it working. I have no idea if this will cause other kinds of bad things to happen later on but at least now I can see my horizontal scroll list.

I also had to change Resources.System.DisplayMetrics to Android.Content.Res.Resources.System.DisplayMetrics in a couple places because I had a local Resources namespace in my project.

There was some warning on ViewRenderer about it being obsolete as of version 2.5 and to fix that I added:

public AndroidHorizontalViewRenderer(Context context) : base(context)
{		
}

Platform.CreateRenderer(viewCell.View) is giving a similar warning but I have not tried to fix that.

2018-06-07 UPDATE

I found it wasn't working on iOS as well and had to do a similar change, copying

Control.DataSource = new iOSViewSource(Element as HorizontalViewNative);
Control.RegisterClassForCell(typeof(iOSViewCell), nameof(iOSViewCell));

and pasting it underneath Control.BackgroundColor = e.NewElement?.BackgroundColor.ToUIColor();

Then my list items would show up but they were all square instead of the rectangular dimentions I had set in the xaml file. To fix that I changed var rect = new CGRect(0, 0, 100, 100); to var rect = new CGRect(0, 0, e.NewElement.ItemWidth, e.NewElement.ItemHeight);

2018-06-19 UPDATE
I have tried using this HorizontalViewNative on both Android and iOS, and on both devices when scrolled too much it will eventually crash. With the Android debugger I got an OutOfMemoryError error, which makes it seem like the views offscreen are not being recycled properly. Have you tried this on a real device with a lot of cells?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant