本文整理汇总了C#中Android.Views.ViewGroup.GetChildAt方法的典型用法代码示例。如果您正苦于以下问题:C# ViewGroup.GetChildAt方法的具体用法?C# ViewGroup.GetChildAt怎么用?C# ViewGroup.GetChildAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Views.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.GetChildAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearUpViewGroup
private static void ClearUpViewGroup(ViewGroup grp)
{
try
{
for (int i = 0; i < grp.ChildCount; i++)
{
var view = grp.GetChildAt(i);
var viewGroup = view as ViewGroup;
if (viewGroup != null)
{
ClearUpViewGroup(viewGroup);
grp.RemoveView(viewGroup);
viewGroup.Dispose();
continue;
}
var imageView = view as ImageView;
if (imageView != null)
imageView.Recycle();
grp.RemoveView(view);
view.Dispose();
view = null;
}
}
catch
{
Console.WriteLine("ClearUpViewGroup Exception");
}
}
示例2: DisableTaskInput
void DisableTaskInput( ViewGroup frame, bool enable )
{
if ( frame as ListView != null || frame as ScrollView != null )
{
frame.Enabled = enable;
frame.Focusable = enable;
frame.FocusableInTouchMode = enable;
}
int i;
for ( i = 0; i < frame.ChildCount; i++ )
{
View child = frame.GetChildAt( i ) as View;
if ( (child as ViewGroup) != null )
{
DisableTaskInput( (child as ViewGroup), enable );
}
else
{
if ( child as ListView != null || child as ScrollView != null )
{
child.Enabled = enable;
child.Focusable = enable;
child.FocusableInTouchMode = enable;
}
}
}
}
示例3: CanScrollUp
bool CanScrollUp(ViewGroup viewGroup)
{
if (viewGroup == null)
return base.CanChildScrollUp();
var sdk = (int)global::Android.OS.Build.VERSION.SdkInt;
if (sdk >= 16)
{
#if __ANDROID_16__
//is a scroll container such as listview, scroll view, gridview
if (viewGroup.IsScrollContainer)
{
return base.CanChildScrollUp();
}
#endif
}
//if you have something custom and you can't scroll up you might need to enable this
//for instance on a custom recycler view where the code above isn't working!
for (int i = 0; i < viewGroup.ChildCount; i++)
{
var child = viewGroup.GetChildAt(i);
if (child is Android.Widget.AbsListView)
{
var list = child as Android.Widget.AbsListView;
if (list != null)
{
if (list.FirstVisiblePosition == 0)
{
var subChild = list.GetChildAt(0);
return subChild != null && subChild.Top != 0;
}
//if children are in list and we are scrolled a bit... sure you can scroll up
return true;
}
}
else if (child is Android.Widget.ScrollView)
{
var scrollview = child as Android.Widget.ScrollView;
return (scrollview.ScrollY <= 0.0);
}
else if (child is Android.Support.V4.Widget.SwipeRefreshLayout)
{
return CanScrollUp(child as ViewGroup);
}
//else if something else like a recycler view?
}
return false;
}
示例4: DisposeChildren
public static void DisposeChildren (ViewGroup vg)
{
if (vg.Handle == IntPtr.Zero) {
// see http://developer.xamarin.com/guides/android/advanced_topics/garbage_collection/#Disposing_of_Peer_instances
return;
}
for (int i = 0; i < vg.ChildCount; i++) {
vg.GetChildAt (i).Dispose ();
}
}
示例5: SetupGravity
private void SetupGravity(ViewGroup view)
{
LinearLayout itemRoot = (LinearLayout)view;
GravityFlags gravityInt = GravityExt.GetGravity(itemGravity);
itemRoot.SetGravity(gravityInt | GravityFlags.CenterVertical);
if (view.ChildCount == 2)
{
if (itemGravity == GravityEnum.End && !IsRtl() && view.GetChildAt(0) is CompoundButton)
{
CompoundButton first = (CompoundButton)view.GetChildAt(0);
view.RemoveView(first);
TextView second = (TextView)view.GetChildAt(0);
view.RemoveView(second);
second.SetPadding(second.PaddingRight, second.PaddingTop,
second.PaddingLeft, second.PaddingBottom);
view.AddView(second);
view.AddView(first);
}
else if (itemGravity == GravityEnum.Start && IsRtl() && view.GetChildAt(1) is CompoundButton)
{
CompoundButton first = (CompoundButton)view.GetChildAt(1);
view.RemoveView(first);
TextView second = (TextView)view.GetChildAt(0);
view.RemoveView(second);
second.SetPadding(second.PaddingRight, second.PaddingTop,
second.PaddingRight, second.PaddingBottom);
view.AddView(first);
view.AddView(second);
}
}
}
示例6: UpdateEditedItemSockets
private static void UpdateEditedItemSockets(ViewGroup layout)
{
var editedGems = new List<SocketedGem>();
for (var index = 0; index < layout.ChildCount; index++)
{
var view = layout.GetChildAt(index);
if (view.FindViewById<Spinner>(Resource.Id.socketLabel) != null)
{
var tag = (JavaLangObject<Item>)(view.Tag);
if (tag != null)
{
Console.WriteLine(tag.Value);
editedGems.Add(new SocketedGem(tag.Value));
}
}
}
D3Context.Instance.EditingItem.Gems = editedGems.ToArray();
}
示例7: UpdateEditedItem
private static void UpdateEditedItem(ViewGroup layout)
{
var numberDecimalSeparator = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
var attr = new ItemAttributes();
for (var index = 0; index < layout.ChildCount; index++)
{
var view = layout.GetChildAt(index);
var editText = view.FindViewById<EditText>(Resource.Id.attributeValue);
if (editText != null)
{
var tag = (JavaLangObject<Field>)(view.Tag);
Console.WriteLine(tag.Value + " = " + editText.Text);
var text = editText.Text.Replace(numberDecimalSeparator == "," ? "." : ",", numberDecimalSeparator);
double value;
if (Double.TryParse(text, out value))
{
tag.Value.SetValue(attr, value);
}
}
}
D3Context.Instance.EditingItem.AttributesRaw += attr;
}
示例8: AddListenterToButtons
private void AddListenterToButtons(ViewGroup parent)
{
for (var i = 0; i < parent.ChildCount; i++)
{
var child = parent.GetChildAt(i);
if (child is ViewGroup)
{
AddListenterToButtons(child as ViewGroup);
}
else if (child is Button)
{
child.SetOnClickListener(this);
}
}
}
示例9: GetTopView
private static View GetTopView(ViewGroup viewGroup)
{
if (viewGroup == null || viewGroup.ChildCount == 0)
return null;
View topView = null;
for (int i = viewGroup.ChildCount - 1; i >= 0; i--)
{
View child = viewGroup.GetChildAt(i);
if (child.Visibility == ViewStates.Visible && child.Top == 0)
{
topView = child;
break;
}
}
return topView;
}
示例10: GetBottomView
private static View GetBottomView(ViewGroup viewGroup)
{
if (viewGroup == null || viewGroup.ChildCount == 0)
return null;
View bottomView = null;
for (int i = viewGroup.ChildCount - 1; i >= 0; i--)
{
View child = viewGroup.GetChildAt(i);
if (child.Visibility == ViewStates.Visible && child.Bottom == viewGroup.MeasuredHeight)
{
bottomView = child;
break;
}
}
return bottomView;
}
示例11: InvalidateDividersForScrollingView
private void InvalidateDividersForScrollingView(ViewGroup view, bool setForTop, bool setForBottom, bool hasButtons)
{
if (setForTop && view.ChildCount > 0)
{
mDrawTopDivider = mTitleBar != null &&
mTitleBar.Visibility != ViewStates.Gone && view.ScrollY + view.PaddingTop > view.GetChildAt(0).Top;
}
if (setForBottom && view.ChildCount > 0)
{
mDrawBottomDivider = hasButtons &&
view.ScrollY + view.Height - view.PaddingBottom < view.GetChildAt(view.ChildCount - 1).Bottom;
}
}
示例12: RemoveBitmapsOfButtonStroked
public static void RemoveBitmapsOfButtonStroked(ViewGroup mainView)
{
for(int i = 0; i < mainView.ChildCount; i++)
{
View child = mainView.GetChildAt(i);
Type childType = child.GetType();
if(childType == typeof(ButtonStroked))
((ButtonStroked)child).RemoveBitmaps();
else if(childType.BaseType == typeof(ViewGroup))
RemoveBitmapsOfButtonStroked((ViewGroup) child);
}
}
示例13: SetThemeOnChildren
static void SetThemeOnChildren(ViewGroup parentViewGroup, FlatTheme theme, bool includeNormalViews)
{
for (int i = 0; i < parentViewGroup.ChildCount; i++)
{
var view = parentViewGroup.GetChildAt (i);
var vtype = view.GetType ();
if (view is FlatButton)
(view as FlatButton).Theme = theme;
else if (view is FlatCheckBox)
(view as FlatCheckBox).Theme = theme;
else if (view is FlatEditText)
(view as FlatEditText).Theme = theme;
else if (view is FlatRadioButton)
(view as FlatRadioButton).Theme = theme;
else if (view is FlatSeekBar)
(view as FlatSeekBar).Theme = theme;
else if (view is FlatTextView)
(view as FlatTextView).Theme = theme;
else if (view is FlatToggleButton)
(view as FlatToggleButton).Theme = theme;
//TODO: Need to add code for settheme static method
if (includeNormalViews)
{
if (vtype == typeof(CheckBox))
FlatCheckBox.SetTheme(view as CheckBox, theme);
else if (vtype == typeof(RadioButton))
FlatRadioButton.SetTheme(view as RadioButton, theme);
else if (vtype == typeof(ToggleButton))
FlatToggleButton.SetTheme(view as ToggleButton, theme);
else if (vtype == typeof(EditText))
FlatEditText.SetTheme(view as EditText, theme);
else if (vtype == typeof(TextView))
FlatTextView.SetTheme(view as TextView, theme);
else if (vtype == typeof(SeekBar))
FlatSeekBar.SetTheme(view as SeekBar, theme);
else if (vtype == typeof(Button))
FlatButton.SetTheme(view as Button, theme);
}
var childViewGroup = view as ViewGroup;
if (childViewGroup != null)
SetThemeOnChildren (childViewGroup, theme, includeNormalViews);
}
}
示例14: GetViews
private IEnumerable<KeyValuePair<string, View>> GetViews(ViewGroup viewGroup)
{
for (int i = 0; i < viewGroup.ChildCount; i++)
{
var view = viewGroup.GetChildAt(i);
var group = view as ViewGroup;
if (group != null)
{
var children = GetViews(group);
foreach (var child in children)
{
yield return child;
}
}
if (view.Id > 0)
{
string name = viewGroup.Context.Resources.GetResourceEntryName(view.Id);
yield return new KeyValuePair<string, View>(name, view);
}
}
}
示例15: initValue
private void initValue(Activity activity)
{
this.activity = activity;
leftMenuItems = new List<ResideMenuItem>();
rightMenuItems = new List<ResideMenuItem>();
ignoredViews = new List<View>();
viewDecor = (ViewGroup)activity.Window.DecorView;
viewActivity = new TouchDisableView(this.activity);
View mContent = viewDecor.GetChildAt(0);
viewDecor.RemoveViewAt(0);
viewActivity.setContent(mContent);
AddView(viewActivity);
ViewGroup parent = (ViewGroup)scrollViewLeftMenu.Parent;
parent.RemoveView(scrollViewLeftMenu);
parent.RemoveView(scrollViewRightMenu);
}