本文整理汇总了Java中android.widget.LinearLayout.indexOfChild方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.indexOfChild方法的具体用法?Java LinearLayout.indexOfChild怎么用?Java LinearLayout.indexOfChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.indexOfChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: switchItemFromPosition
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void switchItemFromPosition(int change,View view){
LinearLayout parentLayout = (LinearLayout)(view.getParent());
int columnPos = parentLayout.indexOfChild(view);
if(columnPos+change >= 0 && columnPos+change < parentLayout.getChildCount()) {
parentLayout.removeView(view);
parentLayout.addView(view, columnPos + change);
if(mDragItemStartCallback != null){
int newPos = parentLayout.indexOfChild(view);
last_swap = System.currentTimeMillis();
mLastSwap = newPos;
int newColumnPos = ((LinearLayout)mobileView.getParent().getParent().getParent().getParent()).indexOfChild((View)(mobileView.getParent().getParent().getParent()));
mDragItemStartCallback.changedPosition(view,originalItemPosition,originalPosition,newPos,newColumnPos);
}
}
}
示例2: setTitleBar
import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
public void setTitleBar(TitleBarView titleBar) {
isSliding = (boolean) SPUtil.get(mContext, SPConstant.SP_KEY_ACTIVITY_TAB_SLIDING, true);
if (isSliding && viewSliding == null) {
viewSliding = View.inflate(mContext, R.layout.layout_activity_sliding, null);
mSlidingTab = viewSliding.findViewById(R.id.tabLayout_slidingActivity);
} else if (!isSliding && viewSegment == null) {
viewSegment = View.inflate(mContext, R.layout.layout_activity_segment, null);
mSegmentTab = viewSegment.findViewById(R.id.tabLayout_segment);
}
LinearLayout center = titleBar.getLinearLayout(Gravity.CENTER);
if (isSliding) {
if (center.indexOfChild(viewSliding) == -1) {
titleBar.addCenterAction(titleBar.new ViewAction(viewSliding));
}
viewSliding.setVisibility(View.VISIBLE);
if (viewSegment != null) {
viewSegment.setVisibility(View.GONE);
}
} else {
if (center.indexOfChild(viewSegment) == -1) {
titleBar.addCenterAction(titleBar.new ViewAction(viewSegment));
}
viewSegment.setVisibility(View.VISIBLE);
if (viewSliding != null) {
viewSliding.setVisibility(View.GONE);
}
}
}