Example usage for android.view ViewGroup getChildAt

List of usage examples for android.view ViewGroup getChildAt

Introduction

In this page you can find the example usage for android.view ViewGroup getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:com.grottworkshop.gwsswipelayout.SwipeLayout.java

/**
 * if the ViewGroup children want to handle this event.
 * @param v the v/*from   w w w.  java2s  . c om*/
 * @param event the event
 * @return v
 */
private View childNeedHandleTouchEvent(ViewGroup v, MotionEvent event) {
    if (v == null)
        return null;
    if (v.onTouchEvent(event))
        return v;

    int childCount = v.getChildCount();
    for (int i = childCount - 1; i >= 0; i--) {
        View child = v.getChildAt(i);
        if (child instanceof ViewGroup) {
            View grandChild = childNeedHandleTouchEvent((ViewGroup) child, event);
            if (grandChild != null)
                return grandChild;
        } else {
            if (childNeedHandleTouchEvent(v.getChildAt(i), event))
                return v.getChildAt(i);
        }
    }
    return null;
}

From source file:dev.dworks.apps.anexplorer.fragment.DirectoryFragment.java

private void setEnabledRecursive(View v, boolean enabled) {
    if (v == null)
        return;/*from w  w  w .  j a  v a2 s . com*/
    if (v.isEnabled() == enabled)
        return;
    v.setEnabled(enabled);

    if (v instanceof ViewGroup) {
        final ViewGroup vg = (ViewGroup) v;
        for (int i = vg.getChildCount() - 1; i >= 0; i--) {
            setEnabledRecursive(vg.getChildAt(i), enabled);
        }
    }
}

From source file:com.inmobi.ultrapush.AnalyzeActivity.java

/**
 * Visit all subviews of this view group and run command
 *
 * @param group  The parent view group/*  w  w  w .j  a  v a2 s .  c  om*/
 * @param cmd    The command to run for each view
 * @param select The tag value that must match. Null implies all views
 */

private void visit(ViewGroup group, Visit cmd, String select) {
    exec(group, cmd, select);
    for (int i = 0; i < group.getChildCount(); i++) {
        View c = group.getChildAt(i);
        if (c instanceof ViewGroup) {
            visit((ViewGroup) c, cmd, select);
        } else {
            exec(c, cmd, select);
        }
    }
}

From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 *               or just its children (false).
 * @param dx Delta scrolled in pixels/*from w w  w.  j  a v  a 2s .co  m*/
 * @param x X coordinate of the active touch point
 * @param y Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}

From source file:dev.dworks.apps.anexplorer.fragment.DirectoryFragment.java

@Override
public void onDestroyView() {
    super.onDestroyView();

    // Cancel any outstanding thumbnail requests
    final ViewGroup target = (mListView.getAdapter() != null) ? mListView : mGridView;
    final int count = target.getChildCount();
    for (int i = 0; i < count; i++) {
        final View view = target.getChildAt(i);
        mRecycleListener.onMovedToScrapHeap(view);
    }/* w  ww.  j  a  va 2  s  .  co m*/

    // Tear down any selection in progress
    mListView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    mGridView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
}

From source file:name.teze.layout.lib.SlidingPaneLayout.java

/** 
 * @param v  /*ww w  .  j a va  2  s.  c o  m*/
 * @author: by Fooyou 201434  ?3:01:23
 */
private void findIgnoredView(View v) {
    /*if(BuildConfig.DEBUG)Log.d(TAG, "findIgnoredView");*/
    if (v instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) v;
        for (int i = 0; i < vg.getChildCount(); i++) {
            final View child = vg.getChildAt(i);
            if (child instanceof ViewPager || child instanceof ScrollView || child instanceof Gallery
                    || child instanceof HorizontalScrollView) {
                mIgnoredViews.add(child);
            } else {
                findIgnoredView(child);
            }
        }
    } else {
        if (v instanceof ViewPager || v instanceof ScrollView || v instanceof Gallery
                || v instanceof HorizontalScrollView) {
            mIgnoredViews.add(v);
        }
    }
}

From source file:com.malin.rxjava.activity.MainActivity.java

/**
 * Remove an onclick listener//from   w w w  .j  av a2s.c  o m
 *
 * @param view
 * @author malin.myemail@gmail.com
 * @website https://github.com/androidmalin
 * @data 2016/01/22
 */
private void unBingListener(View view) {
    if (view != null) {
        try {
            if (view.hasOnClickListeners()) {
                view.setOnClickListener(null);
            }
            if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
                ViewGroup viewGroup = (ViewGroup) view;
                int viewGroupChildCount = viewGroup.getChildCount();
                for (int i = 0; i < viewGroupChildCount; i++) {
                    unBingListener(viewGroup.getChildAt(i));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

From source file:com.malin.rxjava.activity.MainActivity.java

/**
 * ???Activity onDestoryviewrootview//from  w w  w  .  j a  va  2  s .c  o m
 * ?view?DrawingCache??
 * Activity???????
 *
 * @param view:the root view of the layout
 * @description Unbind the rootView
 * @author malin.myemail@gmail.com
 * @link http://stackoverflow.com/questions/9461364/exception-in-unbinddrawables
 * http://mp.weixin.qq.com/s?__biz=MzAwNDY1ODY2OQ==&mid=400656149&idx=1&sn=122b4f4965fafebf78ec0b4fce2ef62a&3rd=MzA3MDU4NTYzMw==&scene=6#rd
 * @since 2015.12.16
 */
private void unBindDrawables(View view) {
    if (view != null) {
        try {
            Drawable drawable = view.getBackground();
            if (drawable != null) {
                drawable.setCallback(null);
            } else {
            }
            if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
                ViewGroup viewGroup = (ViewGroup) view;
                int viewGroupChildCount = viewGroup.getChildCount();
                for (int j = 0; j < viewGroupChildCount; j++) {
                    unBindDrawables(viewGroup.getChildAt(j));
                }
                viewGroup.removeAllViews();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

From source file:activities.PaintActivity.java

public void enableChildsOnTouch(ViewGroup viewGroup, boolean enabled) {
    int cnt = viewGroup.getChildCount();
    for (int i = 0; i < cnt; i++) {
        View v = viewGroup.getChildAt(i);
        if (v instanceof ViewGroup) {
            enableChildsOnTouch((ViewGroup) v, enabled);
        } else {//from  w w  w  . j  a v  a2s  . c om
            v.setEnabled(enabled);

        }
    }
}

From source file:co.codecrunch.musicplayerlite.slidinguppanelhelper.SlidingUpPanelLayout.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v// www .j ava2 s.  c  om
 *            View to test for horizontal scrollability
 * @param checkV
 *            Whether the view v passed should itself be checked for
 *            scrollability (true), or just its children (false).
 * @param dx
 *            Delta scrolled in pixels
 * @param x
 *            X coordinate of the active touch point
 * @param y
 *            Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance
        // first.
        for (int i = count - 1; i >= 0; i--) {
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }
    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}