summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/ViewGroupExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/ViewGroupExtensions.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ViewGroupExtensions.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ViewGroupExtensions.cs b/Xamarin.Forms.Platform.Android/Renderers/ViewGroupExtensions.cs
new file mode 100644
index 00000000..dfcb9ca2
--- /dev/null
+++ b/Xamarin.Forms.Platform.Android/Renderers/ViewGroupExtensions.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using AView = Android.Views.View;
+using AViewGroup = Android.Views.ViewGroup;
+
+namespace Xamarin.Forms.Platform.Android
+{
+ internal static class ViewGroupExtensions
+ {
+ internal static IEnumerable<T> GetChildrenOfType<T>(this AViewGroup self) where T : AView
+ {
+ for (var i = 0; i < self.ChildCount; i++)
+ {
+ AView child = self.GetChildAt(i);
+ var typedChild = child as T;
+ if (typedChild != null)
+ yield return typedChild;
+
+ if (child is AViewGroup)
+ {
+ IEnumerable<T> myChildren = (child as AViewGroup).GetChildrenOfType<T>();
+ foreach (T nextChild in myChildren)
+ yield return nextChild;
+ }
+ }
+ }
+ }
+} \ No newline at end of file