Java Code Examples for android.widget.LinearLayout#indexOfChild()

The following examples show how to use android.widget.LinearLayout#indexOfChild() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: BoardView   File: BoardView.java    License: Apache License 2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example 2
Source Project: FastLib   File: ActivityFragment.java    License: Apache License 2.0 5 votes vote down vote up
@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),
                    new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        }
        viewSliding.setVisibility(View.VISIBLE);
        if (viewSegment != null) {
            viewSegment.setVisibility(View.GONE);
        }
    } else {
        if (center.indexOfChild(viewSegment) == -1) {
            titleBar.addCenterAction(titleBar.new ViewAction(viewSegment),
                    new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        }
        viewSegment.setVisibility(View.VISIBLE);
        if (viewSliding != null) {
            viewSliding.setVisibility(View.GONE);
        }
    }
    setTab();
}