List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
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 .j av a 2s . co 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:com.dmbstream.android.util.Util.java
private static void findNotificationTextColors(ViewGroup group, String title, String content) { for (int i = 0; i < group.getChildCount(); i++) { if (group.getChildAt(i) instanceof TextView) { TextView textView = (TextView) group.getChildAt(i); String text = textView.getText().toString(); if (title.equals(text)) { NOTIFICATION_TEXT_COLORS.setFirst(textView.getTextColors().getDefaultColor()); } else if (content.equals(text)) { NOTIFICATION_TEXT_COLORS.setSecond(textView.getTextColors().getDefaultColor()); }// w w w . j a v a2s . c o m } else if (group.getChildAt(i) instanceof ViewGroup) findNotificationTextColors((ViewGroup) group.getChildAt(i), title, content); } }
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; }// w w w .ja va 2 s . co 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.xander.panel.PanelController.java
/** * view ??//from w w w . j a v a 2 s.c om * * @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:info.papdt.blacklight.support.Utility.java
public static void setActionBarTranslation(Activity activity, float y) { ViewGroup vg = (ViewGroup) activity.findViewById(android.R.id.content).getParent(); int count = vg.getChildCount(); if (DEBUG) {/*w ww . jav a2 s .c om*/ Log.d(TAG, "=========================="); } // Get the class of action bar Class<?> actionBarContainer = null; Field isSplit = null; try { actionBarContainer = Class.forName("com.android.internal.widget.ActionBarContainer"); isSplit = actionBarContainer.getDeclaredField("mIsSplit"); isSplit.setAccessible(true); } catch (Exception e) { if (DEBUG) { Log.e(TAG, Log.getStackTraceString(e)); } } for (int i = 0; i < count; i++) { View v = vg.getChildAt(i); if (v.getId() != android.R.id.content) { if (DEBUG) { Log.d(TAG, "Found View: " + v.getClass().getName()); } try { if (actionBarContainer.isInstance(v)) { if (DEBUG) { Log.d(TAG, "Found ActionBarContainer"); } if (isSplit.getBoolean(v)) { if (DEBUG) { Log.d(TAG, "Found Split Action Bar"); } continue; } } } catch (Exception e) { if (DEBUG) { Log.e(TAG, Log.getStackTraceString(e)); } } v.setTranslationY(y); } } if (DEBUG) { Log.d(TAG, "=========================="); } }
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); }/*from w w w. ja v a 2 s . co m*/ } }
From source file:android.support.v7.app.AlertController.java
static boolean canTextInput(View v) { if (v.onCheckIsTextEditor()) { return true; }// www.ja v a 2 s .co 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:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java
public static int idNumFromIdString(View view, String id) { if (!(view instanceof ViewGroup)) return 0; Object tag = view.getTag();/* w w w. j av a2s.com*/ 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: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);/*w w w .j a va2 s . c o m*/ } else if (v instanceof ViewGroup) { views.addAll(getTextViews((ViewGroup) v)); } } return views; }
From source file:com.proma.Nerd.Main_Page.java
public void setFont(ViewGroup group, Typeface font) { int count = group.getChildCount(); View v;//from w ww .ja va2 s . com for (int i = 0; i < count; i++) { v = group.getChildAt(i); if (v instanceof TextView || v instanceof Button || v instanceof EditText) ((TextView) v).setTypeface(font); else if (v instanceof ViewGroup) setFont((ViewGroup) v, font); } }