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

The following are Jave code examples for showing how to use indexOfChild() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: BoardView   File: BoardView.java   View Source Code Vote up 5 votes
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
Project: FastLib   File: ActivityFragment.java   View Source Code Vote up 5 votes
@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);
        }
    }
}