I've seen many tutorials/samples for Xamarin.Forms, but none for Xamarin.Android..
@Krestek You put your ListView inside a "android.support.v4.widget.SwipeRefreshLayout".
My layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
In OnViewCreated() of my fragment I do this and that is all there is to it:
_swipeRefresh = view.FindViewById<SwipeRefreshLayout>(Resource.Id.swiperefresh);
if (_swipeRefresh != null)
var weakTarget = new WeakReference<ContainerListFragment<T>>(this);
_swipeRefresh.Refresh += (sender, e) =>
if (weakTarget.TryGetTarget(out ContainerListFragment<T> target)) target.ReloadData(true);
Thanks, I've understood the axml part, but I didn't understand the weakTarget in the C# code.. I mean, we get the view, and we assign a function to the refresh event, but why is there a _swiperefresh!=null condition and a weak target variable?
I use this same code for layouts that might not have a swipe refresh so you can get rid of that check. You should get it working without worrying about the weak stuff. I use it just to make sure I don't have cyclic references. Not sure if it is really needed in this case.
When I work a lot on Xamarin.iOS, I get into the habit of putting weak stuff in.
Ah okay then, it worked. Thank you!
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies