本文整理汇总了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);
}
});
}
}
}
示例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();
}
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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));
}
}
}
示例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);
}
示例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);
}
}
}
示例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));
}
示例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;
}
示例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());
}
}