Refine search
public static int findChildIndex(ViewGroup parent, View child) { int count = parent.getChildCount(); for (int i = 0; i < count; ++i) { if (parent.getChildAt(i) == child) { return i; } } return -1; } }
private BottomBarTab findTabInLayout(ViewGroup child) { for (int i = 0; i < child.getChildCount(); i++) { View candidate = child.getChildAt(i); if (candidate instanceof BottomBarTab) { return (BottomBarTab) candidate; } } return null; }
/** * @return inflated progress view or null */ public View getProgressView() { if (mProgressView.getChildCount() > 0) return mProgressView.getChildAt(0); return null; }
TextView textView = null; ViewGroup row = (ViewGroup) v.getParent(); for (int itemPos = 0; itemPos < row.getChildCount(); itemPos++) { View view = row.getChildAt(itemPos); if (view instanceof TextView) { textView = (TextView) view; //Found it! break; } }
/** * @return inflated error view or null */ public View getErrorView() { if (mErrorView.getChildCount() > 0) return mErrorView.getChildAt(0); return null; }
/** * @return inflated empty view or null */ public View getEmptyView() { if (mEmptyView.getChildCount() > 0) return mEmptyView.getChildAt(0); return null; }
private void changeTabsFont() { ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0); int tabsCount = vg.getChildCount(); for (int j = 0; j < tabsCount; j++) { ViewGroup vgTab = (ViewGroup) vg.getChildAt(j); int tabChildsCount = vgTab.getChildCount(); for (int i = 0; i < tabChildsCount; i++) { View tabViewChild = vgTab.getChildAt(i); if (tabViewChild instanceof TextView) { ((TextView) tabViewChild).setTypeface(Font.getInstance().getTypeFace(), Typeface.NORMAL); } } } }
/** * simple helper method to reset the selection of the sticky footer */ protected void resetStickyFooterSelection() { if (mStickyFooterView instanceof LinearLayout) { for (int i = 0; i < (mStickyFooterView).getChildCount(); i++) { (mStickyFooterView).getChildAt(i).setActivated(false); (mStickyFooterView).getChildAt(i).setSelected(false); } } } }
public static List<View> getChildrenOfView(View view) { ArrayList<View> children = new ArrayList<>(); if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup)view; int count = viewGroup.getChildCount(); for (int i = 0; i < count; i++) { children.add(viewGroup.getChildAt(i)); } } return children; }
private static List<View> findVisibleChildren(ViewGroup viewGroup) { List<View> visibleViews = new ArrayList<>(); final int childCount = viewGroup.getChildCount(); for (int i = 0; i < childCount; i++) { View child = viewGroup.getChildAt(i); if (child.getVisibility() == View.VISIBLE) { visibleViews.add(child); } } return visibleViews; }
@Implementation protected void setDisplayedChild(int whichChild) { currentChild = whichChild; for (int i = ((ViewGroup) realView).getChildCount() - 1; i >= 0; i--) { View child = ((ViewGroup) realView).getChildAt(i); child.setVisibility(i == whichChild ? View.VISIBLE : View.GONE); } }
private static void wrapperCoordinatorLayout(ViewGroup layout/*, final RefreshLayout refreshLayout*/, final CoordinatorLayoutListener listener) { for (int i = layout.getChildCount() - 1; i >= 0; i--) { View view = layout.getChildAt(i); if (view instanceof AppBarLayout) { ((AppBarLayout) view).addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { listener.onCoordinatorUpdate( verticalOffset >= 0, /*refreshLayout.isEnableLoadMore() && */ (appBarLayout.getTotalScrollRange() + verticalOffset) <= 0); } }); } } }
private void disableEnableControls(boolean enable, ViewGroup vg){ for (int i = 0; i < vg.getChildCount(); i++){ View child = vg.getChildAt(i); child.setEnabled(enable); if (child instanceof ViewGroup){ disableEnableControls(enable, (ViewGroup)child); } } }
protected View findScrollableViewInternal(View content, boolean selfable) { View scrollableView = null; Queue<View> views = new LinkedList<>(Collections.singletonList(content)); while (!views.isEmpty() && scrollableView == null) { View view = views.poll(); if (view != null) { if ((selfable || view != content) && isContentView(view)) { scrollableView = view; } else if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int j = 0; j < group.getChildCount(); j++) { views.add(group.getChildAt(j)); } } } } return scrollableView == null ? content : scrollableView; }
/** * Unbind all drawables to avoid memory leaks. * Link: http://stackoverflow.com/a/6779164/1590502 * * @param view */ private void unbindDrawables(View view) { if (view.getBackground() != null) { view.getBackground().setCallback(null); } if (view instanceof ViewGroup) { for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { unbindDrawables(((ViewGroup) view).getChildAt(i)); } ((ViewGroup) view).removeAllViews(); } }
void logContentView(View parent, String indent) { Log.i("test", indent + parent.getClass().getName()); if (parent instanceof ViewGroup) { ViewGroup group = (ViewGroup)parent; for (int i = 0; i < group.getChildCount(); i++) logContentView(group.getChildAt(i), indent + " "); } }
private void overrideFonts(final Context context, final View v) { try { if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; for (int i = 0; i < vg.getChildCount(); i++) { View child = vg.getChildAt(i); overrideFonts(context, child); } } else if (v instanceof TextView ) { ((TextView) v).setTypeface(Typeface.createFromAsset(context.getAssets(), "font.ttf")); } } catch (Exception e) { } }
private void clearForm(ViewGroup group) { for (int i = 0, count = group.getChildCount(); i < count; ++i) { View view = group.getChildAt(i); if (view instanceof EditText) { ((EditText)view).setText(""); } if(view instanceof ViewGroup && (((ViewGroup)view).getChildCount() > 0)) clearForm((ViewGroup)view); } }
private static void setViewAndChildrenEnabled(View view, boolean enabled) { view.setEnabled(enabled); if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; for (int i = 0; i < viewGroup.getChildCount(); i++) { View child = viewGroup.getChildAt(i); setViewAndChildrenEnabled(child, enabled); } } }
private View findDeepestChild(ViewGroup viewGroup) { if (viewGroup.getChildCount() == 0) { return viewGroup; } View lastChild = viewGroup.getChildAt(viewGroup.getChildCount() - 1); if (lastChild instanceof ViewGroup) { return findDeepestChild((ViewGroup)lastChild); } else { return lastChild; } }