Example usage for android.widget LinearLayout removeViews

List of usage examples for android.widget LinearLayout removeViews

Introduction

In this page you can find the example usage for android.widget LinearLayout removeViews.

Prototype

public void removeViews(int start, int count) 

Source Link

Document

Removes the specified range of views from the group.

Usage

From source file:org.ale.scanner.zotero.BibDetailJSONAdapter.java

public void fillLinearLayout(LinearLayout layout) {
    int childCount = layout.getChildCount();
    // Layout might not be the view we used last time, so
    // remove any views we won't need
    if (mNumFilledFields < childCount) {
        layout.removeViews(mNumFilledFields, layout.getChildCount() - mNumFilledFields);
    }/*from  w  ww. jav  a  2 s . co  m*/

    // Edit any of the already attached views
    for (int entry = 0; entry < mNumFilledFields; entry++) {
        if (entry < childCount) {
            View v = layout.getChildAt(entry);
            getView(entry, v, layout);
        } else {
            layout.addView(getView(entry, null, layout));
        }
    }
}

From source file:com.narkii.security.info.BaseDataFragment.java

/**
 * /*from   www . j  a  v a 2  s.  com*/
 * @param view view
 */
private void clearPersonInfoView(View view) {
    final LinearLayout parent = (LinearLayout) view.getParent().getParent();
    Log.d(TAG, "remove person view: " + parent.getChildCount());
    if (parent.getChildCount() > 1) {
        parent.removeViews(1, parent.getChildCount() - 1);
    }
}

From source file:com.google.samples.apps.iosched.ui.widget.CollectionView.java

private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) {
    ViewGroup groupView;//from ww  w.  j av a  2  s .  co  m
    if (view != null && view instanceof ViewGroup) {
        groupView = (ViewGroup) view;
        // If there are more children in the recycled view we remove the extra ones.
        if (groupView.getChildAt(0) instanceof LinearLayout) {
            LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0);
            if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) {
                groupViewContent.removeViews(rowInfo.group.getRowCount(),
                        groupViewContent.getChildCount() - rowInfo.group.getRowCount());
            }
        }
        // Use the defined callbacks if the user has chosen to by implementing a
        // CardsCollectionViewCallbacks.
    } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) {
        groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks)
                .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent);
        // This should never happened but if it does we'll display an EmptyView.
    } else {
        LOGE(TAG, "Tried to create a group view but the callback is not an instance of "
                + "GroupCollectionViewCallbacks");
        return new EmptyView(getContext());
    }
    LinearLayout groupViewContent;
    if (groupView.getChildAt(0) instanceof LinearLayout) {
        groupViewContent = (LinearLayout) groupView.getChildAt(0);
    } else {
        groupViewContent = new LinearLayout(getContext());
        groupViewContent.setOrientation(LinearLayout.VERTICAL);
        LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        groupViewContent.setLayoutParams(LLParams);
        groupView.addView(groupViewContent);
    }
    disableCustomGroupView();
    for (int i = 0; i < rowInfo.group.getRowCount(); i++) {
        View itemView;
        try {
            itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent);
        } catch (Exception e) {
            // Recycling failed (maybe the items were not compatible) so we start again without
            // recycling.
            itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent);
        }
        if (itemView != groupViewContent.getChildAt(i)) {
            if (groupViewContent.getChildCount() > i) {
                groupViewContent.removeViewAt(i);
            }
            groupViewContent.addView(itemView, i);
        }
    }
    enableCustomGroupView();
    return groupView;
}

From source file:com.razza.apps.iosched.ui.widget.CollectionView.java

private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) {
    ViewGroup groupView;/*from   w  w w  .jav  a 2 s.co m*/
    if (view != null && view instanceof ViewGroup) {
        groupView = (ViewGroup) view;
        // If there are more children in the recycled view we remove the extra ones.
        if (groupView.getChildAt(0) instanceof LinearLayout) {
            LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0);
            if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) {
                groupViewContent.removeViews(rowInfo.group.getRowCount(),
                        groupViewContent.getChildCount() - rowInfo.group.getRowCount());
            }
        }
        // Use the defined callbacks if the user has chosen to by implementing a
        // CardsCollectionViewCallbacks.
    } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) {
        groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks)
                .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent);
        // This should never happened but if it does we'll display an EmptyView.
    } else {
        LogUtils.LOGE(TAG, "Tried to create a group view but the callback is not an instance of "
                + "GroupCollectionViewCallbacks");
        return new EmptyView(getContext());
    }
    LinearLayout groupViewContent;
    if (groupView.getChildAt(0) instanceof LinearLayout) {
        groupViewContent = (LinearLayout) groupView.getChildAt(0);
    } else {
        groupViewContent = new LinearLayout(getContext());
        groupViewContent.setOrientation(LinearLayout.VERTICAL);
        LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        groupViewContent.setLayoutParams(LLParams);
        groupView.addView(groupViewContent);
    }
    disableCustomGroupView();
    for (int i = 0; i < rowInfo.group.getRowCount(); i++) {
        View itemView;
        try {
            itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent);
        } catch (Exception e) {
            // Recycling failed (maybe the items were not compatible) so we start again without
            // recycling.
            itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent);
        }
        if (itemView != groupViewContent.getChildAt(i)) {
            if (groupViewContent.getChildCount() > i) {
                groupViewContent.removeViewAt(i);
            }
            groupViewContent.addView(itemView, i);
        }
    }
    enableCustomGroupView();
    return groupView;
}

From source file:com.httrack.android.HTTrackActivity.java

private void removeLinesFromLayout(final LinearLayout layout, final int fromPosition) {
    if (fromPosition < layout.getChildCount()) {
        layout.removeViews(fromPosition, layout.getChildCount() - fromPosition);
    }//  w w  w.  j  a  v a 2s  .  co  m
}