當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。