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.battlelancer.seriesguide.widgets.EmptyViewSwipeRefreshLayout.java

@Override
public boolean canChildScrollUp() {
    // find content view
    ViewGroup target = null;
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        if (child instanceof ImageView) {
            continue;
        }//from   w w  w  .j ava  2  s  . c o m
        target = (ViewGroup) child;
    }

    if (target == null) {
        return false;
    }

    // check if adapter view is visible
    View scrollableView = target.getChildAt(1);
    if (scrollableView.getVisibility() == GONE) {
        // use empty view layout instead
        scrollableView = target.getChildAt(0);
    }

    return ViewCompat.canScrollVertically(scrollableView, -1);
}

From source file:com.bamalearn.bamalearnburmese.DrawerMainActivity.java

private void changeSearchViewTextColor(View view) {
    if (view != null) {
        if (view instanceof TextView) {
            ((TextView) view).setTextColor(Color.WHITE);
            ((TextView) view).setHintTextColor(Color.WHITE);
            return;
        } else if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i = 0; i < viewGroup.getChildCount(); i++) {
                changeSearchViewTextColor(viewGroup.getChildAt(i));
            }//from w w w .  ja va 2s .  c om
        }
    }
}

From source file:com.twotoasters.jazzylistview.JazzyHelper.java

/**
 * Initializes the item view and triggers the animation.
 *
 * @param item            The view to be animated.
 * @param position        The index of the view in the list.
 * @param scrollDirection Positive number indicating scrolling down, or negative number indicating scrolling up.
 *///from  ww w . j a v  a  2s  .co m
private void doJazziness(View item, int position, int scrollDirection) {
    if (mIsScrolling) {
        if (mOnlyAnimateNewItems && mAlreadyAnimatedItems.contains(position))
            return;

        if (mOnlyAnimateOnFling && !mIsFlingEvent)
            return;

        if (mMaxVelocity > MAX_VELOCITY_OFF && mMaxVelocity < mSpeed)
            return;

        if (mSimulateGridWithList) {
            ViewGroup itemRow = (ViewGroup) item;
            for (int i = 0; i < itemRow.getChildCount(); i++)
                doJazzinessImpl(itemRow.getChildAt(i), position, scrollDirection);
        } else {
            doJazzinessImpl(item, position, scrollDirection);
        }

        mAlreadyAnimatedItems.add(position);
    }
}

From source file:com.docd.purefm.ui.activities.SearchActivity.java

private void initList() {
    if (mList != null) {
        final View emptyView = mList.getEmptyView();
        if (emptyView != null) {
            emptyView.setVisibility(View.GONE);
        }/* w  ww.  j a va 2  s  .  c o  m*/
        mList.setVisibility(View.GONE);
    }

    final ViewGroup listContainer = (ViewGroup) findViewById(R.id.list_container);
    if (listContainer == null) {
        throw new RuntimeException("parent should contain ViewGroup with id R.id.list_container");
    }

    final Settings settings = getSettings();
    final View swipeRefreshList;
    switch (settings.getListAppearance()) {
    case LIST:
        swipeRefreshList = getLayoutInflater().inflate(R.layout.browser_listview, listContainer);
        break;

    case GRID:
        swipeRefreshList = getLayoutInflater().inflate(R.layout.browser_gridview, listContainer);
        break;

    default:
        throw new IllegalArgumentException("Unexpected ListApeparance: " + settings.getListAppearance());
    }

    if (swipeRefreshList == null) {
        throw new RuntimeException("Inflated View is null");
    }

    final ViewGroup swipeRefreshLayoutList = (ViewGroup) swipeRefreshList
            .findViewById(R.id.browser_list_swipe_refresh);

    mList = (AbsListView) swipeRefreshLayoutList.getChildAt(0);
    if (mList instanceof ListView) {
        mAdapter = new BrowserListAdapter(this);
    } else {
        mAdapter = new BrowserGridAdapter(this);
    }

    mList.setEmptyView(findViewById(android.R.id.empty));
    mList.setAdapter(mAdapter);
    final View emptyView = mList.getEmptyView();
    if (emptyView != null) {
        emptyView.setVisibility(View.GONE);
    }
    mList.setVisibility(View.GONE);

    mActionModeController.setListView(mList);

    mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> av, View v, int pos, long id) {
            final GenericFile target = (GenericFile) av.getItemAtPosition(pos);
            if (target == null) {
                throw new RuntimeException("Item at position is null");
            }
            PFMFileUtils.openFileInExternalApp(SearchActivity.this, target.toFile());
        }
    });
}

From source file:jp.co.noxi.app.NXDatePickerDialog.java

DatePicker findDatePicker(View view) {
    if (view == null) {
        return null;
    }//from  w w w  .jav  a 2s .c  o m
    if (view instanceof DatePicker) {
        return (DatePicker) view;
    }
    if (!(view instanceof ViewGroup)) {
        return null;
    }

    final ViewGroup viewGroup = (ViewGroup) view;
    final int count = viewGroup.getChildCount();
    if (count == 0) {
        return null;
    }
    for (int i = 0; i < count; i++) {
        DatePicker datePicker = findDatePicker(viewGroup.getChildAt(i));
        if (datePicker != null) {
            return datePicker;
        }
    }
    return null;
}

From source file:fr.julienvermet.bugdroid.ui.phone.BugActivity.java

/**
 * Searches the view hierarchy excluding the content view for a possible
 * Spinner in the ActionBar.//from ww  w .j av a2  s.c o  m
 * 
 * @param root
 *            The parent of the content view
 * @param position
 *            The position that should be selected
 * @return if the spinner was found and adjusted
 */
private boolean findAndUpdateSpinner(Object root, int position) {
    if (root instanceof android.widget.Spinner) {
        // Found the Spinner
        Spinner spinner = (Spinner) root;
        spinner.setSelection(position);
        return true;
    } else if (root instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) root;
        if (group.getId() != android.R.id.content) {
            // Found a container that isn't the container holding our screen
            // layout
            for (int i = 0; i < group.getChildCount(); i++) {
                if (findAndUpdateSpinner(group.getChildAt(i), position)) {
                    // Found and done searching the View tree
                    return true;
                }
            }
        }
    }
    // Nothing found
    return false;
}

From source file:com.bryan.lib.util.TabUtils.java

private View getRealChild(View child) {
    View realChild = null;//w w w.  ja  v  a 2  s  .c om
    //viewgroup,????  android:clickable="false"
    if (child instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) child;

        if (group.getChildCount() == 1) {
            realChild = ((ViewGroup) child).getChildAt(0);
        }
        //viewgroup1?tag
        else if (group.getChildCount() > 1) {
            for (int i = 0; i < group.getChildCount(); i++) {
                if (group.getChildAt(i).getTag() != null) {
                    realChild = group.getChildAt(i);
                    break;
                }
            }

        } else {
            realChild = child;
        }

    } else if (child instanceof View) {
        realChild = child;
    }
    return realChild;
}

From source file:com.quinsoft.zeidon.android.ZeidonAndroidViewDelegate.java

/**
 * Loop through all the children of viewGroup and copy values from an OI to the view.
 *
 * @param viewGroup/*  w ww  . j  a v a2 s. c  o m*/
 */
public void setChildrenFromOi(ViewGroup viewGroup) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        android.view.View child = viewGroup.getChildAt(i);
        if (child instanceof ZeidonDisplayView)
            ((ZeidonDisplayView) child).setFromOi();
        else if (child instanceof ViewGroup)
            setChildrenFromOi((ViewGroup) child);
    }
}

From source file:com.quinsoft.zeidon.android.ZeidonAndroidViewDelegate.java

/**
 * Loop through all the children of viewGroup and copy values from the Android
 * views to the OI./*from   ww w.  ja  va  2s .  c om*/
 *
 * @param viewGroup
 */
public void copyValuesToOi(ViewGroup viewGroup) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        android.view.View child = viewGroup.getChildAt(i);
        if (child instanceof ZeidonInputView)
            ((ZeidonInputView) child).copyValuesToOi();
        else if (child instanceof ViewGroup)
            copyValuesToOi((ViewGroup) child);
    }
}

From source file:com.tomeokin.lspush.ui.widget.SwipeRefreshLayoutWithEmpty.java

@Override
public boolean canChildScrollUp() {
    // The swipe refresh layout has 2 children; the circle refresh indicator
    // and the view container. The container is needed here
    ViewGroup container = getContainer();
    if (container == null) {
        return false;
    }/*  w w w. j av  a  2  s.  c  om*/

    // The container has 2 children; the empty view and the scrollable view.
    if (container.getChildCount() != 2) {
        throw new RuntimeException("Container must have an empty view and content view");
    }

    // Use whichever one is visible and test that it can scroll
    View view = container.getChildAt(0);
    if (view.getVisibility() != View.VISIBLE) {
        view = container.getChildAt(1);
    }

    return ViewCompat.canScrollVertically(view, -1);
}