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