當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewGroup.getChildCount方法代碼示例

本文整理匯總了Java中android.view.ViewGroup.getChildCount方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewGroup.getChildCount方法的具體用法?Java ViewGroup.getChildCount怎麽用?Java ViewGroup.getChildCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.getChildCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setOnItemClickListener

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 為任意ViewGroup設置OnItemClickListener.
 * 該方法必須在addViews()方法之後調用,否則無效。
 * 因為ItemView 必須被添加在ViewGroup裏才能遍曆到。
 * 建議直接在addViews()方法裏傳入OnItemClickListener進行設置,性能更高
 *
 * @param viewGroup
 * @param onItemClickListener
 */
public static void setOnItemClickListener(final ViewGroup viewGroup, final OnItemClickListener onItemClickListener) {
    if (viewGroup == null || onItemClickListener == null) {
        return;
    }
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View itemView = viewGroup.getChildAt(i);
        //itemView之前沒有點擊事件才會去設置
        if (null != itemView && !itemView.isClickable()) {
            final int finalI = i;
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    onItemClickListener.onItemClick(viewGroup, itemView, finalI);
                }
            });
        }
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:29,代碼來源:ViewGroupUtils.java

示例2: viewClick

import android.view.ViewGroup; //導入方法依賴的package包/類
private void viewClick(ViewGroup view, MotionEvent e ) {
    if (inViewInBounds(view, (int) e.getX(), (int) e.getY()) && view.hasOnClickListeners()) {
        view.callOnClick();
    }
    View child;
    for (int i = 0; i < view.getChildCount(); i++) {
        child = view.getChildAt(i);
        if (child instanceof ViewGroup) {
            viewClick((ViewGroup) child, e);
        } else {
            if (inViewInBounds(child, (int) e.getX(), (int) e.getY()) && child.hasOnClickListeners()) {
                child.callOnClick();
            }
        }
    }
}
 
開發者ID:xiaoshanlin000,項目名稱:SLTableView,代碼行數:17,代碼來源:StickyRecyclerHeadersTouchListener.java

示例3: setKeyColorRecursive

import android.view.ViewGroup; //導入方法依賴的package包/類
private static void setKeyColorRecursive(ViewGroup vg) {
    if (vg == null) return;
    final int childCount = vg.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = vg.getChildAt(i);
        if (child instanceof ViewGroup) {
            setKeyColorRecursive((ViewGroup) child);
        } else if (child instanceof ImageView) {
            ImageView imgv = (ImageView) vg.getChildAt(i);
            if (mNavbarColorsEnabled) {
                imgv.setColorFilter(mKeyColor, PorterDuff.Mode.SRC_ATOP);
            } else {
                imgv.clearColorFilter();
            }
            if (imgv.getClass().getName().equals(CLASS_KEY_BUTTON_VIEW) &&
                    !mNavbarColorsEnabled) {
                Drawable ripple = imgv.getBackground();
                if (ripple != null &&
                        ripple.getClass().getName().equals(CLASS_KEY_BUTTON_RIPPLE)) {
                    Paint paint = (Paint) XposedHelpers.getObjectField(ripple, "mRipplePaint");
                    if (paint != null) {
                        paint.setColor(0xffffffff);
                    }
                }
            } else if (imgv instanceof KeyButtonView) {
                ((KeyButtonView) imgv).setGlowColor(mNavbarColorsEnabled ?
                        mKeyGlowColor : mKeyDefaultGlowColor);
            }
        }
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:32,代碼來源:ModNavigationBar.java

示例4: recurseSearchNotificationPrimaryText

import android.view.ViewGroup; //導入方法依賴的package包/類
private boolean recurseSearchNotificationPrimaryText(ViewGroup gp) {
    final int count = gp.getChildCount();
    for (int i = 0; i < count; ++i) {
        if (gp.getChildAt(i) instanceof TextView){
            final TextView text = (TextView) gp.getChildAt(i);
            final String szText = text.getText().toString();
            if (TO_SEARCH.equals(szText)) {
                notificationPrimaryTextColor = text.getTextColors().getDefaultColor();
                return true;
            }
        } else if (gp.getChildAt(i) instanceof ViewGroup) {
            if(recurseSearchNotificationPrimaryText((ViewGroup) gp.getChildAt(i))) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:19,代碼來源:SipNotifications.java

示例5: addSeenViews

import android.view.ViewGroup; //導入方法依賴的package包/類
private static void addSeenViews(List<RouterTransaction> stack, ViewGroup container) {
  ListIterator<RouterTransaction> iterable = stack.listIterator(stack.size());
  int index = container.getChildCount();
  boolean isTop = true;
  while(iterable.hasPrevious()) {
    Controller controller = iterable.previous().controller();
    // Ensure the view is shown
    View view = controller.getView();
    if (view == null) {
      view = controller.inflate(container);
    }
    if (view.getParent() == null) {
      container.addView(view, index);
    }
    // Update index
    index = container.indexOfChild(view);
    // Check controller opacity
    int opacity = getControllerOpacity(controller);
    if (opacity == ControllerOpacity.OPAQUE ||
        (opacity == ControllerOpacity.TRANSLUCENT && !isTop)) {
      // The controllers below can't be seen
      break;
    }
    isTop = false;
  }
}
 
開發者ID:seven332,項目名稱:conductor-attacher,代碼行數:27,代碼來源:ControllerAttacher.java

示例6: setRootView

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 設置根布局參數
 */
private static void setRootView(Activity activity) {
    ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content);
    for (int i = 0, count = parent.getChildCount(); i < count; i++) {
        View childView = parent.getChildAt(i);
        if (childView instanceof ViewGroup) {
            childView.setFitsSystemWindows(true);
            ((ViewGroup) childView).setClipToPadding(true);
        }
    }
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:14,代碼來源:BarUtils.java

示例7: setupButtonDropTarget

import android.view.ViewGroup; //導入方法依賴的package包/類
private void setupButtonDropTarget(View view, DragController dragController) {
    if (view instanceof ButtonDropTarget) {
        ButtonDropTarget bdt = (ButtonDropTarget) view;
        bdt.setDropTargetBar(this);
        dragController.addDragListener(bdt);
        dragController.addDropTarget(bdt);
    } else if (view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) view;
        for (int i = vg.getChildCount() - 1; i >= 0; i--) {
            setupButtonDropTarget(vg.getChildAt(i), dragController);
        }
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:14,代碼來源:DropTargetBar.java

示例8: updateTabLayout

import android.view.ViewGroup; //導入方法依賴的package包/類
private void updateTabLayout() {
    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) {
                if (font != null)
                    ((TextView) tabViewChild).setTypeface(font);
            }
        }
    }
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:16,代碼來源:VideoDetailsFragment.java

示例9: findTopChildUnder

import android.view.ViewGroup; //導入方法依賴的package包/類
static View findTopChildUnder(ViewGroup parent,int x, int y) {
    final int childCount = parent.getChildCount();
    for (int i = childCount - 1; i >= 0; i--) {
        final View child = parent.getChildAt(i);
        if (x >= child.getLeft() && x < child.getRight()
                && y >= child.getTop() && y < child.getBottom()) {
            return child;
        }
    }
    return null;
}
 
開發者ID:AndroidBoySC,項目名稱:Mybilibili,代碼行數:12,代碼來源:SwipeItemLayout.java

示例10: onChildViewAdded

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override public void onChildViewAdded(View parent, View child) {
  delegate.onChildViewAdded(parent, child);

  if (child instanceof ViewGroup) {
    ViewGroup childGroup = (ViewGroup) child;
    childGroup.setOnHierarchyChangeListener(this);
    for (int i = 0; i < childGroup.getChildCount(); i++) {
      onChildViewAdded(childGroup, childGroup.getChildAt(i));
    }
  }
}
 
開發者ID:rogues-dev,項目名稱:superglue,代碼行數:12,代碼來源:HierarchyTreeChangeListener.java

示例11: onMeasure

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (!allowWidthFull)
        return;
    ViewGroup tabsLayout = getTabsLayout();
    if (tabsLayout == null
            || tabsLayout.getMeasuredWidth() >= getMeasuredWidth())
        return;
    if (tabsLayout.getChildCount() <= 0)
        return;

    if (tabViews == null) {
        tabViews = new ArrayList<View>();
    } else {
        tabViews.clear();
    }
    for (int w = 0; w < tabsLayout.getChildCount(); w++) {
        tabViews.add(tabsLayout.getChildAt(w));
    }

    adjustChildWidthWithParent(
            tabViews,
            getMeasuredWidth() - tabsLayout.getPaddingLeft()
                    - tabsLayout.getPaddingRight(), widthMeasureSpec,
            heightMeasureSpec);

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:31,代碼來源:PagerSlidingTabStrip.java

示例12: removeChildGift

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 移除指定framelayout下麵的禮物view
 * @param index
 */
private void removeChildGift(int index) {
    if (index < getChildCount() && getChildAt(index) instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) getChildAt(index);
        if (vg.getChildCount() > 0) {
            vg.removeViewAt(0);
        }
    }
}
 
開發者ID:Yuphee,項目名稱:RewardLayout,代碼行數:13,代碼來源:RewardLayout.java

示例13: addTranslucentView

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 添加半透明矩形條
 *
 * @param activity       需要設置的 activity
 * @param statusBarAlpha 透明值
 */
private static void addTranslucentView(Activity activity, int statusBarAlpha) {
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    // 移除半透明矩形,以免疊加
    if (contentView.getChildCount() > 1) {
        contentView.removeViewAt(1);
    }
    contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:StatusBarUtil.java

示例14: apply

import android.view.ViewGroup; //導入方法依賴的package包/類
public boolean apply(ViewGroup viewGroup) {
    apply((View) viewGroup);
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View view = viewGroup.getChildAt(i);
        if (isInIgnoreSkinActivity(view)) {
            return true;
        }
        if (view instanceof ViewGroup) {
            apply((ViewGroup) view);
        } else {
            apply(view);
        }
    }
    return true;
}
 
開發者ID:MeetYouDevs,項目名稱:Android-Skin,代碼行數:16,代碼來源:AndroidSkinFactory.java

示例15: attachTrackerFrameLayout

import android.view.ViewGroup; //導入方法依賴的package包/類
public void attachTrackerFrameLayout(Activity activity) {
    // this is a problem: several activity exist in the TabActivity
    if (activity == null || activity instanceof TabActivity) {
        return;
    }


    // exist android.R.id.content not found crash
    try {
        ViewGroup container = (ViewGroup) activity.findViewById(android.R.id.content);

        if (container == null) {
            return;
        }

        if (container.getChildCount() > 0) {
            View root = container.getChildAt(0);
            if (root instanceof TrackerFrameLayout) {
                TrackerLog.d("no attachTrackerFrameLayout " + activity.toString());
            } else {
                TrackerFrameLayout trackerFrameLayout = new TrackerFrameLayout(activity);

                while (container.getChildCount() > 0) {
                    View view = container.getChildAt(0);
                    container.removeViewAt(0);
                    trackerFrameLayout.addView(view, view.getLayoutParams());
                }

                container.addView(trackerFrameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            }
        }
    } catch (Exception e) {
        TrackerLog.e(e.toString());
    }

}
 
開發者ID:alibaba,項目名稱:android_viewtracker,代碼行數:37,代碼來源:TrackerManager.java


注:本文中的android.view.ViewGroup.getChildCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。