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.samsung.msca.samsungvr.sampleapp.Util.java

public static void setEnabled(List<View> viewGroupStack, View v, boolean enabled) {

    if (null == viewGroupStack) {
        viewGroupStack = new ArrayList<>();
    }//w  w w  . jav  a2s.c  o m
    viewGroupStack.clear();
    viewGroupStack.add(v);

    while (viewGroupStack.size() > 0) {
        View current = viewGroupStack.remove(0);
        current.setEnabled(enabled);
        if (current instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup) current;
            for (int i = vg.getChildCount() - 1; i >= 0; i -= 1) {
                viewGroupStack.add(vg.getChildAt(i));
            }
        }
    }
}

From source file:io.github.runassudo.ptoffline.utils.TransportrUtils.java

static private void addLineBox(Context context, ViewGroup lineLayout, Line line, int index,
        boolean check_duplicates) {
    if (check_duplicates) {
        // loop through all line boxes in the linearLayout
        for (int i = 0; i < lineLayout.getChildCount(); ++i) {
            // check if current line box is the same as the one we are about to add
            if (line.label != null && line.label.equals(((LineView) lineLayout.getChildAt(i)).getLabel())) {
                // lines are equal, so bail out from here and don't add new line box
                return;
            }/*  www.  jav  a2  s.c  o m*/
        }
    }

    LineView lineView = new LineView(context);
    lineView.setLine(line);

    // set margin, because setting in in xml does not work
    FlowLayout.LayoutParams llp = new FlowLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    llp.setMargins(0, 5, 15, 5);
    lineView.setLayoutParams(llp);

    lineLayout.addView(lineView, index);
}

From source file:com.xander.panel.PanelController.java

/**
 *  view ??/*from   w  ww . ja va  2 s.c  o  m*/
 *
 * @param v
 * @return
 */
static boolean canTextInput(View v) {
    if (v.onCheckIsTextEditor()) {
        return true;
    }
    if (!(v instanceof ViewGroup)) {
        return false;
    }

    ViewGroup vg = (ViewGroup) v;
    int i = vg.getChildCount();
    while (i > 0) {
        i--;
        v = vg.getChildAt(i);
        if (canTextInput(v)) {
            return true;
        }
    }
    return false;
}

From source file:com.mobicage.rogerthat.util.ui.UIUtils.java

public static void setColorsRecursive(Context context, ViewGroup viewGroup) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        final View view = viewGroup.getChildAt(i);
        if (!(view instanceof FrameLayout) && !(view instanceof LinearLayout)
                && !(view instanceof RelativeLayout)) {
            UIUtils.setColors(context, view);
        } else if (view instanceof ViewGroup) {
            UIUtils.setColorsRecursive(context, (ViewGroup) view);
        }//  w ww .  j av  a  2 s .  c  o m
    }
}

From source file:de.grobox.liberario.utils.TransportrUtils.java

static private void addLineBox(Context context, ViewGroup lineLayout, Line line, int index,
        boolean check_duplicates) {
    if (check_duplicates) {
        // loop through all line boxes in the linearLayout
        for (int i = 0; i < lineLayout.getChildCount(); ++i) {
            // check if current line box is the same as the one we are about to add
            if (line.label != null && line.label.equals(((LineView) lineLayout.getChildAt(i)).getLabel())) {
                // lines are equal, so bail out from here and don't add new line box
                return;
            }/* www .ja  v  a2s .c o  m*/
        }
    }

    LineView lineView = new LineView(context);
    lineView.setLine(line);

    // set margin, because setting in in xml does not work
    FlowLayout.LayoutParams llp = new FlowLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    llp.setMargins(0, 5, 10, 5);
    lineView.setLayoutParams(llp);

    lineLayout.addView(lineView, index);
}

From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java

public static int idNumFromIdString(View view, String id) {
    if (!(view instanceof ViewGroup))
        return 0;
    Object tag = view.getTag();//from  ww  w .  j  a  va  2s  .c om
    if (!(tag instanceof DynamicLayoutInfo))
        return 0; // not inflated by this class
    DynamicLayoutInfo info = (DynamicLayoutInfo) view.getTag();
    if (!info.nameToIdNumber.containsKey(id)) {
        ViewGroup grp = (ViewGroup) view;
        for (int i = 0; i < grp.getChildCount(); i++) {
            int val = idNumFromIdString(grp.getChildAt(i), id);
            if (val != 0)
                return val;
        }
        return 0;
    }
    return info.nameToIdNumber.get(id);
}

From source file:android.support.v7.app.AlertController.java

static boolean canTextInput(View v) {
    if (v.onCheckIsTextEditor()) {
        return true;
    }/*from w w w  .j  a  va2  s.  c  o m*/

    if (!(v instanceof ViewGroup)) {
        return false;
    }

    ViewGroup vg = (ViewGroup) v;
    int i = vg.getChildCount();
    while (i > 0) {
        i--;
        v = vg.getChildAt(i);
        if (canTextInput(v)) {
            return true;
        }
    }

    return false;
}

From source file:de.sindzinski.wetter.util.Utility.java

public static HashSet<TextView> getTextViews(ViewGroup root) {
    HashSet<TextView> views = new HashSet<>();
    for (int i = 0; i < root.getChildCount(); i++) {
        View v = root.getChildAt(i);
        if (v instanceof TextView) {
            views.add((TextView) v);/*from   w  w w.ja v a2s.  c o m*/
        } else if (v instanceof ViewGroup) {
            views.addAll(getTextViews((ViewGroup) v));
        }
    }
    return views;
}

From source file:com.draekko.traypreferencesapp.SampleAppPreferences.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
    LinearLayout content = (LinearLayout) root.getChildAt(0);
    LinearLayout toolbarContainer = (LinearLayout) View.inflate(this, R.layout.toolbar, null);

    root.removeAllViews();//www .  jav  a2 s.c om
    toolbarContainer.addView(content);
    root.addView(toolbarContainer);

    mToolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar);
    mToolbar.setTitleTextColor(ContextCompat.getColor(this, R.color.white));
    mToolbar.setSubtitleTextColor(ContextCompat.getColor(this, R.color.white));
    mToolbar.setNavigationIcon(R.drawable.ic_back_material_light);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:com.android.messaging.ui.CustomHeaderViewPagerTest.java

public void testBindFirstLevel() {
    final CustomHeaderViewPager view = new CustomHeaderViewPager(getActivity(), null);
    final SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), 0, null, null, null, 0);
    final CustomHeaderPagerViewHolder[] viewHolders = { new FakeListViewHolder(getActivity(), adapter),
            new FakeListViewHolder(getActivity(), adapter) };

    view.setViewHolders(viewHolders);/* w w w.  j a va 2  s.c  o m*/
    final ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
    final ViewGroup tabStrip = (ViewGroup) view.findViewById(R.id.tab_strip);
    final ViewPagerTabStrip realTab = (ViewPagerTabStrip) tabStrip.getChildAt(0);

    assertEquals(2, realTab.getChildCount());
    View headerTitleButton = realTab.getChildAt(1);
    // Click on the first page. Now the view pager should switch to that page accordingly.
    clickButton(headerTitleButton);
    assertEquals(1, pager.getCurrentItem());
}