blob: dfcb9ca29984e1f4bf6cae2c2fc0b79a530a476c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
}
}
}
}
}
|