当前位置: 首页>>代码示例>>Java>>正文


Java ViewGroup.indexOfChild方法代码示例

本文整理汇总了Java中android.view.ViewGroup.indexOfChild方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.indexOfChild方法的具体用法?Java ViewGroup.indexOfChild怎么用?Java ViewGroup.indexOfChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.indexOfChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 保存view的信息
 *
 * @param view
 */
public void save(View view)
{
    reset();

    if (view != null)
    {
        mParams = view.getLayoutParams();

        final ViewParent viewParent = view.getParent();
        if (viewParent instanceof ViewGroup)
        {
            final ViewGroup viewGroup = (ViewGroup) viewParent;
            setParent(viewGroup);
            mIndex = viewGroup.indexOfChild(view);
        }
    }
}
 
开发者ID:zj565061763,项目名称:windowmanager,代码行数:23,代码来源:SDViewHelper.java

示例2: removeChildGift

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 移除指定framelayout下面的礼物view
 * @param view
 */
private void removeChildGift(View view) {
    for(int i=0;i<getChildCount();i++) {
        ViewGroup vg = (ViewGroup)getChildAt(i);
        final int index = vg.indexOfChild(view);
        if (index >= 0) {
            vg.removeView(view);
            BaseGiftBean bean = (BaseGiftBean)view.getTag();
            int giftId = bean.getGiftId();
            int userId = bean.getUserId();
            for (Iterator<BaseGiftBean> it = beans.iterator(); it.hasNext();) {
                BaseGiftBean value = it.next();
                if (value.getGiftId() == giftId && value.getUserId() == userId) {
                    it.remove();
                }
            }
        }
    }
}
 
开发者ID:Yuphee,项目名称:RewardLayout,代码行数:23,代码来源:RewardLayout.java

示例3: setTargetView

import android.view.ViewGroup; //导入方法依赖的package包/类
public void setTargetView(View target) {
    if (getParent() != null) {
        ((ViewGroup) getParent()).removeView(this);
    }
    if (target != null) {
        if (target.getParent() instanceof FrameLayout) {
            ((FrameLayout) target.getParent()).addView(this);
        } else if (target.getParent() instanceof ViewGroup) {
            ViewGroup parentContainer = (ViewGroup) target.getParent();
            int groupIndex = parentContainer.indexOfChild(target);
            parentContainer.removeView(target);
            FrameLayout badgeContainer = new FrameLayout(getContext());
            ViewGroup.LayoutParams parentlayoutParams = target.getLayoutParams();
            badgeContainer.setLayoutParams(parentlayoutParams);
            target.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
            parentContainer.addView(badgeContainer, groupIndex, parentlayoutParams);
            badgeContainer.addView(target);
            badgeContainer.addView(this);
        } else if (target.getParent() == null) {
            Log.e(getClass().getSimpleName(), "ParentView is needed");
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:NewBadgeView.java

示例4: attachToView

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * Attached the menu into an existing view. The target view will be removed
 * from it's parent and moved inside the sliding menu. The sliding menu
 * will then replace the view inside the original parent. This makes it
 * possible to slide only certain parts of the activity vies, for example
 * if you have a custom toolbar etc. that you don't want to be moved when
 * the menu is visible.
 */
public void attachToView(View view) {
    checkNotAttached();
    
    ViewGroup parent = (ViewGroup)view.getParent();
    int index = parent.indexOfChild(view);
    parent.removeViewAt(index);
 
    setContentView(view);
    
    parent.addView(mPager, index);
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:20,代码来源:SlideMenu.java

示例5: attachTo

import android.view.ViewGroup; //导入方法依赖的package包/类
private void attachTo(View view) {
    ViewParent viewParent = view.getParent();
    ViewGroup parent = (ViewGroup) viewParent;
    int index = parent.indexOfChild(view);
    parent.removeView(view);
    attachmentRoot = new FrameLayout(view.getContext());
    attachmentRoot.setLayoutParams(view.getLayoutParams());
    view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    attachmentRoot.addView(view);
    if (child != null) {
        attachmentRoot.addView(child);
    }
    parent.addView(attachmentRoot, index);
}
 
开发者ID:yanweiqiang,项目名称:IndexView-Android,代码行数:15,代码来源:ViewAttachment.java

示例6: replaceView

import android.view.ViewGroup; //导入方法依赖的package包/类
void replaceView(View originalView, View newView) {
    originalView.setTag(newView);

    newView.setLayoutParams(new FrameLayout.LayoutParams(originalView.getLayoutParams()));

    ViewGroup parent = (ViewGroup) originalView.getParent();
    int index = parent.indexOfChild(originalView);
    parent.removeView(originalView);

    parent.addView(newView, index);
}
 
开发者ID:csarron,项目名称:renderscript_examples,代码行数:12,代码来源:MainActivity.java

示例7: hasChildView

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 判断父控件是否包含某个子View
 *
 * @param father
 * @param child
 * @return
 */
public static boolean hasChildView(ViewGroup father, View child) {
    boolean had = false;
    try {
        had = father.indexOfChild(child) != -1;
    } catch (Exception e) {
    }
    return had;
}
 
开发者ID:AriesHoo,项目名称:TitleBarView,代码行数:16,代码来源:TitleBarView.java

示例8: setupContent

import android.view.ViewGroup; //导入方法依赖的package包/类
private void setupContent(ViewGroup contentPanel) {
    mScrollView = (NestedScrollView) mWindow.findViewById(R.id.scrollView);
    mScrollView.setFocusable(false);
    mScrollView.setNestedScrollingEnabled(false);

    // Special case for users that only want to display a String
    mMessageView = (TextView) contentPanel.findViewById(android.R.id.message);
    if (mMessageView == null) {
        return;
    }

    if (mMessage != null) {
        mMessageView.setText(mMessage);
    } else {
        mMessageView.setVisibility(View.GONE);
        mScrollView.removeView(mMessageView);

        if (mListView != null) {
            final ViewGroup scrollParent = (ViewGroup) mScrollView.getParent();
            final int childIndex = scrollParent.indexOfChild(mScrollView);
            scrollParent.removeViewAt(childIndex);
            scrollParent.addView(mListView, childIndex,
                    new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
        } else {
            // contentPanel.setVisibility(View.GONE);
        }
    }
}
 
开发者ID:pranavpandey,项目名称:dynamic-dialogs,代码行数:29,代码来源:DynamicAlertController.java

示例9: onCreateView

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View layout = super.onCreateView(inflater, container, savedInstanceState);

	ListView lv = (ListView) layout.findViewById(android.R.id.list);
	ViewGroup parent = (ViewGroup) lv.getParent();

	// Remove ListView and add PullToRefreshListView in its place
	int lvIndex = parent.indexOfChild(lv);
	parent.removeViewAt(lvIndex);
	mPullToRefreshListView = onCreatePullToRefreshListView(inflater, savedInstanceState);
	parent.addView(mPullToRefreshListView, lvIndex, lv.getLayoutParams());

	return layout;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:16,代码来源:PullToRefreshBaseListFragment.java

示例10: judgeIndexIsChanged

import android.view.ViewGroup; //导入方法依赖的package包/类
private boolean judgeIndexIsChanged(View view, LastViewInfo lastViewInfo, ViewGroup parent) {
    if (parent instanceof RecyclerView) {
        return lastViewInfo.index == ((RecyclerView) parent).getChildAdapterPosition(view);
    } else {
        return lastViewInfo.index == parent.indexOfChild(view);
    }
}
 
开发者ID:LikangR,项目名称:TvHelper,代码行数:8,代码来源:ViewFocusHandler.java

示例11: applyTo

import android.view.ViewGroup; //导入方法依赖的package包/类
private void applyTo(View target) {
    LayoutParams lp = target.getLayoutParams();
    ViewParent parent = target.getParent();
    FrameLayout container = new FrameLayout(this.context);
    ViewGroup group = (ViewGroup) parent;
    int index = group.indexOfChild(target);
    group.removeView(target);
    group.addView(container, index, lp);
    container.addView(target);
    container.addView(this);
    group.invalidate();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:BottomRedPointView.java

示例12: swapViewGroupChildren

import android.view.ViewGroup; //导入方法依赖的package包/类
public static void swapViewGroupChildren(ViewGroup viewGroup, View firstView, View secondView) {
    int firstIndex = viewGroup.indexOfChild(firstView);
    int secondIndex = viewGroup.indexOfChild(secondView);
    if (firstIndex < secondIndex) {
        viewGroup.removeViewAt(secondIndex);
        viewGroup.removeViewAt(firstIndex);
        viewGroup.addView(secondView, firstIndex);
        viewGroup.addView(firstView, secondIndex);
    } else {
        viewGroup.removeViewAt(firstIndex);
        viewGroup.removeViewAt(secondIndex);
        viewGroup.addView(firstView, secondIndex);
        viewGroup.addView(secondView, firstIndex);
    }
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:16,代码来源:AppUtils.java

示例13: create

import android.view.ViewGroup; //导入方法依赖的package包/类
public MaterialRippleLayout create() {
    MaterialRippleLayout layout = new MaterialRippleLayout(context);
    layout.setRippleColor(rippleColor);
    layout.setDefaultRippleAlpha(rippleAlpha);
    layout.setRippleDelayClick(rippleDelayClick);
    layout.setRippleDiameter((int) dpToPx(context.getResources(), rippleDiameter));
    layout.setRippleDuration(rippleDuration);
    layout.setRippleFadeDuration(rippleFadeDuration);
    layout.setRippleHover(rippleHover);
    layout.setRipplePersistent(ripplePersistent);
    layout.setRippleOverlay(rippleOverlay);
    layout.setRippleBackground(rippleBackground);
    layout.setRippleInAdapter(rippleSearchAdapter);
    layout.setRippleRoundedCorners((int) dpToPx(context.getResources(), rippleRoundedCorner));

    ViewGroup.LayoutParams params = child.getLayoutParams();
    ViewGroup parent = (ViewGroup) child.getParent();
    int index = 0;

    if (parent != null && parent instanceof MaterialRippleLayout) {
        throw new IllegalStateException("MaterialRippleLayout could not be created: parent of the view already is a MaterialRippleLayout");
    }

    if (parent != null) {
        index = parent.indexOfChild(child);
        parent.removeView(child);
    }

    layout.addView(child, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

    if (parent != null) {
        parent.addView(layout, index, params);
    }

    return layout;
}
 
开发者ID:yangchong211,项目名称:YCUtils,代码行数:37,代码来源:MaterialRippleLayout.java

示例14: updateLastViewInfo

import android.view.ViewGroup; //导入方法依赖的package包/类
private void updateLastViewInfo(View newFocus, ViewGroup parent, LastViewInfo lastViewInfo) {
    if (parent instanceof RecyclerView) {
        lastViewInfo.index = ((RecyclerView) parent).getChildAdapterPosition(newFocus);
    } else {
        lastViewInfo.index = parent.indexOfChild(newFocus);
    }
    Log.d("updateLastViewInfo", "index:" + lastViewInfo.index);
    lastViewInfo.view = newFocus;
}
 
开发者ID:LikangR,项目名称:TvHelper,代码行数:10,代码来源:ViewFocusHandler.java

示例15: setTargetView

import android.view.ViewGroup; //导入方法依赖的package包/类
public void setTargetView(View target) {
    if (getParent() != null) {
        ((ViewGroup) getParent()).removeView(this);
    }

    if (target == null) {
        return;
    }

    if (target.getParent() instanceof FrameLayout) {
        ((FrameLayout) target.getParent()).addView(this);

    } else if (target.getParent() instanceof ViewGroup) {
        // use a new Framelayout container for adding badge
        ViewGroup parentContainer = (ViewGroup) target.getParent();
        int groupIndex = parentContainer.indexOfChild(target);
        parentContainer.removeView(target);

        FrameLayout badgeContainer = new FrameLayout(getContext());
        ViewGroup.LayoutParams parentLayoutParams = target.getLayoutParams();

        badgeContainer.setLayoutParams(parentLayoutParams);
        target.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        parentContainer.addView(badgeContainer, groupIndex, parentLayoutParams);
        badgeContainer.addView(target);

        badgeContainer.addView(this);
    } else if (target.getParent() == null) {
        Log.e(getClass().getSimpleName(), "ParentView is needed");
    }

}
 
开发者ID:Gofar,项目名称:TitleBar,代码行数:35,代码来源:BadgeView.java


注:本文中的android.view.ViewGroup.indexOfChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。