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

The following are Jave code examples for showing how to use removeView() 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: ActivityTaskView   File: ActivityTaskView.java   View Source Code Vote up 6 votes
public void remove(ActivityTask.TaskInfo taskInfo) {
    int taskId = taskInfo.getTaskId();
    LinearLayout layout = mLayoutMap.get(taskId);
    if (layout == null) {
        Log.e(TAG, "LinearLayout not found");
        return;
    }
    ObserverTextView textView = mObserverTextViewMap.remove(taskInfo.getActivityId());
    if (textView == null) {
        Log.e(TAG, "ObserverTextView not found");
        return;
    }
    mObservable.deleteObserver(textView);
    layout.removeView(textView);
    Log.i(TAG, "removeObserverTextView " + taskId);
    if (layout.getChildCount() == 0) {
        mLayoutMap.remove(taskId);
        removeView(layout);
        Log.i(TAG, "removeLinearLayout " + taskId);
    }
}
 
Example 2
Project: home-automation   File: StoryActivity.java   View Source Code Vote up 6 votes
private void removeDeviceFromStory(DeviceDAO deviceToFind) {
    final List<DeviceDAO> devices = story.getDevices();
    if (devices.remove(deviceToFind)) {
        this.lastRemovedDevice = deviceToFind;
    }
    story.setDevices(devices);
    LinearLayout mainLinearLayout = findViewById(R.id.mainLinearLayout);
    View deviceView = mainLinearLayout.findViewById(deviceToFind.getId());
    mainLinearLayout.removeView(deviceView);

    // Add the possibility to restore a device in the list
    Snackbar.make(mainLinearLayout, getString(R.string.snackbar_device_removed_from_story), Snackbar.LENGTH_LONG)
        .setAction(getString(R.string.cancel), new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (lastRemovedDevice != null) {
                    story.getDevices().add(lastRemovedDevice);
                    populateDevices();
                }
            }
        })
        .show();
    populateDevices();
}
 
Example 3
Project: encdroidMC   File: EDFileChooserActivity.java   View Source Code Vote up 6 votes
protected void onPreExecute() {
	super.onPreExecute();

	// Replace the ListView with a ProgressBar
	mProgBar = new ProgressBar(EDFileChooserActivity.this, null,
			android.R.attr.progressBarStyleLarge);

	// Set the layout to fill the screen
	mListView = EDFileChooserActivity.this.getListView();
	mLayout = (LinearLayout) mListView.getParent();
	mLayout.setGravity(Gravity.CENTER);
	mLayout.setLayoutParams(new FrameLayout.LayoutParams(
			LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

	// Set the ProgressBar in the center of the layout
	LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	layoutParams.gravity = Gravity.CENTER;
	mProgBar.setLayoutParams(layoutParams);

	// Replace the ListView with the ProgressBar
	mLayout.removeView(mListView);
	mLayout.addView(mProgBar);
	mProgBar.setVisibility(View.VISIBLE);
}
 
Example 4
Project: decoy   File: MsgViewHolderBase.java   View Source Code Vote up 6 votes
private void setContent() {
    if (!isShowBubble() && !isMiddleItem()) {
        return;
    }

    LinearLayout bodyContainer = (LinearLayout) view.findViewById(R.id.message_item_body);

    // 调整container的位置
    int index = isReceivedMessage() ? 0 : 3;
    if (bodyContainer.getChildAt(index) != contentContainer) {
        bodyContainer.removeView(contentContainer);
        bodyContainer.addView(contentContainer, index);
    }

    if (isMiddleItem()) {
        setGravity(bodyContainer, Gravity.CENTER);
    } else {
        if (isReceivedMessage()) {
            setGravity(bodyContainer, Gravity.LEFT);
            contentContainer.setBackgroundResource(leftBackground());
        } else {
            setGravity(bodyContainer, Gravity.RIGHT);
            contentContainer.setBackgroundResource(rightBackground());
        }
    }
}
 
Example 5
Project: decoy   File: ChatRoomMsgViewHolderBase.java   View Source Code Vote up 6 votes
private void setContent() {
    if (!isShowBubble() && !isMiddleItem()) {
        return;
    }

    LinearLayout bodyContainer = (LinearLayout) view.findViewById(R.id.message_item_body);

    // 调整container的位置
    int index = isReceivedMessage() ? 0 : 3;
    if (bodyContainer.getChildAt(index) != contentContainer) {
        bodyContainer.removeView(contentContainer);
        bodyContainer.addView(contentContainer, index);
    }

    if (isMiddleItem()) {
        setGravity(bodyContainer, Gravity.CENTER);
    } else {
        if (isReceivedMessage()) {
            setGravity(bodyContainer, Gravity.LEFT);
            contentContainer.setBackgroundResource(leftBackground());
        } else {
            setGravity(bodyContainer, Gravity.RIGHT);
            contentContainer.setBackgroundResource(rightBackground());
        }
    }
}
 
Example 6
Project: android-random-selector   File: EnterOptionsActivity.java   View Source Code Vote up 5 votes
public void removeEntry(View view) {
    // Remove the last entry in the list
    LinearLayout entriesList = (LinearLayout) this.findViewById(R.id.entriesList);
    entriesList.removeView(entries.get(entries.size() - 1));
    entries.remove(entries.size() - 1);

    // Set the minus button's enabled state appropriately
    configureMinusButtonEnabledState();
}
 
Example 7
Project: AOdia   File: OperationFragment.java   View Source Code Vote up 5 votes
public void deleteOpeView(OperationView operationView){
    final LinearLayout listView=(LinearLayout) findViewById(R.id.opeListView);
    for(int i=0;i<listView.getChildCount();i++){
        if(listView.getChildAt(i)==operationView){
            operationView.operation.removeAllTrain();
            diaFile.operationList.get(diaNum).remove(operationView.operation);
            listView.removeView(operationView);
            break;
        }
    }
}
 
Example 8
Project: home-automation   File: StoryActivity.java   View Source Code Vote up 5 votes
/**
 *
 */
private void populateDevices() {
    final LinearLayout mainLinearLayout = findViewById(R.id.mainLinearLayout);
    final CardView addPictureCard = findViewById(R.id.addPictureCard);

    for (final DeviceDAO deviceDAO : story.getDevices()) {
        final View previousDeviceView = mainLinearLayout.findViewById(deviceDAO.getId());
        if (previousDeviceView != null) {
            mainLinearLayout.removeView(previousDeviceView);
        }
        final View deviceView = getLayoutInflater().inflate(R.layout.story_activity_card_device, mainLinearLayout, false);

        // Pass args to buttons in order to perfom some actions on the device
        Button deleteDevice = deviceView.findViewById(R.id.delete_device);
        deleteDevice.setTag(R.id.cardDevice, deviceDAO);

        Button configureDevice = deviceView.findViewById(R.id.configure_device);
        configureDevice.setTag(R.id.cardDevice, deviceDAO);

        deviceView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                showRemoveDeviceDialog(deviceDAO);
                return true;
            }
        });

        // Hide the text if the device has no NetBios name (should be improved by the way)
        TextView name = deviceView.findViewById(R.id.name);
        if (deviceDAO.getName() == null) {
            name.setVisibility(View.GONE);
        } else {
            name.setText(deviceDAO.getName());
        }

        TextView ip = deviceView.findViewById(R.id.ip);
        ip.setText(deviceDAO.getIP());
        TextView vendor = deviceView.findViewById(R.id.vendor);
        vendor.setText(deviceDAO.getVendor());

        // Show the lock icon if device is password protected
        if (deviceDAO.isProtected()) {
            ImageView lockIcon = deviceView.findViewById(R.id.lockIcon);
            lockIcon.setVisibility(View.VISIBLE);
        }

        deviceView.setId(deviceDAO.getId());
        mainLinearLayout.addView(deviceView, mainLinearLayout.indexOfChild(addPictureCard));
    }
}
 
Example 9
Project: FastAndroid   File: MultiVideoCallActivity.java   View Source Code Vote up 5 votes
@Override
public void onRemoteUserLeft(String userId, RongCallCommon.CallDisconnectedReason reason) {
    //incoming状态,localViewUserId为空
    if (localViewUserId == null)
        return;
    if (localViewUserId.equals(userId)) {
        localViewContainer.removeAllViews();
        String currentUserId = RongIMClient.getInstance().getCurrentUserId();
        FrameLayout remoteVideoView = (FrameLayout) remoteViewContainer.findViewWithTag(currentUserId);
        localView = (SurfaceView) remoteVideoView.getChildAt(0);
        remoteVideoView.removeAllViews();
        localViewContainer.addView(localView);
        TextView topUserNameView = (TextView) topContainer.findViewById(R.id.rc_voip_user_name);
        topUserNameView.setTag(currentUserId + "name");
        UserInfo userInfo = RongContext.getInstance().getUserInfoFromCache(currentUserId);
        if (userInfo != null) {
            topUserNameView.setText(userInfo.getName());
        } else {
            topUserNameView.setText(currentUserId);
        }
        localViewUserId = currentUserId;
    }

    View singleRemoteView = remoteViewContainer.findViewWithTag(userId + "view");

    if (singleRemoteView == null)
        return;

    LinearLayout container = (LinearLayout) singleRemoteView.getParent();
    container.removeView(singleRemoteView);
    if (container.equals(remoteViewContainer2)) {
        if (remoteViewContainer1.getChildCount() > 0) {
            View childView = remoteViewContainer1.getChildAt(0);
            remoteViewContainer1.removeView(childView);
            remoteViewContainer2.addView(childView);
        }
    }
}
 
Example 10
Project: FastAndroid   File: CallUserGridView.java   View Source Code Vote up 5 votes
public void removeChild(String childId) {
    int containerCount = linearLayout.getChildCount();

    LinearLayout lastContainer = null;
    List<LinearLayout> containerList = new ArrayList<>();
    for (int i = 0; i < containerCount; i++) {
        LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
        containerList.add(container);
    }
    for (LinearLayout resultContainer : containerList) {
        if (lastContainer == null) {
            LinearLayout child = (LinearLayout) resultContainer.findViewWithTag(childId);
            if (child != null) {
                resultContainer.removeView(child);
                if (resultContainer.getChildCount() == 0) {
                    linearLayout.removeView(resultContainer);
                    break;
                } else {
                    lastContainer = resultContainer;
                }
            }
        } else {
            View view = resultContainer.getChildAt(0);
            resultContainer.removeView(view);
            lastContainer.addView(view);
            if (resultContainer.getChildCount() == 0) {
                linearLayout.removeView(resultContainer);
                break;
            } else {
                lastContainer = resultContainer;
            }
        }
    }
}
 
Example 11
Project: chromium-for-android-56-debug-video   File: InfoBarControlLayout.java   View Source Code Vote up 5 votes
/**
 * Adds an icon with a descriptive message to the layout.
 *
 * -----------------------------------------------------
 * | ICON | PRIMARY MESSAGE SECONDARY MESSAGE          |
 * -----------------------------------------------------
 * If an icon is not provided, the ImageView that would normally show it is hidden.
 *
 * @param iconResourceId   ID of the drawable to use for the icon.
 * @param iconColorId      ID of the tint color for the icon, or 0 for default.
 * @param primaryMessage   Message to display for the toggle.
 * @param secondaryMessage Additional descriptive text for the toggle.  May be null.
 */
public View addIcon(int iconResourceId, int iconColorId, CharSequence primaryMessage,
        CharSequence secondaryMessage) {
    LinearLayout layout = (LinearLayout) LayoutInflater.from(getContext()).inflate(
            R.layout.infobar_control_icon_with_description, this, false);
    addView(layout, new ControlLayoutParams());

    ImageView iconView = (ImageView) layout.findViewById(R.id.control_icon);
    iconView.setImageResource(iconResourceId);
    if (iconColorId != 0) {
        iconView.setColorFilter(ApiCompatibilityUtils.getColor(getResources(), iconColorId));
    }

    // The primary message text is always displayed.
    TextView primaryView = (TextView) layout.findViewById(R.id.control_message);
    primaryView.setText(primaryMessage);

    // The secondary message text is optional.
    TextView secondaryView =
            (TextView) layout.findViewById(R.id.control_secondary_message);
    if (secondaryMessage == null) {
        layout.removeView(secondaryView);
    } else {
        secondaryView.setText(secondaryMessage);
    }

    return layout;
}
 
Example 12
Project: chromium-for-android-56-debug-video   File: InfoBarControlLayout.java   View Source Code Vote up 5 votes
/**
 * Creates a standard toggle switch and adds it to the layout.
 *
 * -------------------------------------------------
 * | ICON | MESSAGE                       | TOGGLE |
 * -------------------------------------------------
 * If an icon is not provided, the ImageView that would normally show it is hidden.
 *
 * @param iconResourceId ID of the drawable to use for the icon, or 0 to hide the ImageView.
 * @param iconColorId    ID of the tint color for the icon, or 0 for default.
 * @param toggleMessage  Message to display for the toggle.
 * @param toggleId       ID to use for the toggle.
 * @param isChecked      Whether the toggle should start off checked.
 */
public View addSwitch(int iconResourceId, int iconColorId, CharSequence toggleMessage,
        int toggleId, boolean isChecked) {
    LinearLayout switchLayout = (LinearLayout) LayoutInflater.from(getContext()).inflate(
            R.layout.infobar_control_toggle, this, false);
    addView(switchLayout, new ControlLayoutParams());

    ImageView iconView = (ImageView) switchLayout.findViewById(R.id.control_icon);
    if (iconResourceId == 0) {
        switchLayout.removeView(iconView);
    } else {
        iconView.setImageResource(iconResourceId);
        if (iconColorId != 0) {
            iconView.setColorFilter(
                    ApiCompatibilityUtils.getColor(getResources(), iconColorId));
        }
    }

    TextView messageView = (TextView) switchLayout.findViewById(R.id.control_message);
    messageView.setText(toggleMessage);

    SwitchCompat switchView =
            (SwitchCompat) switchLayout.findViewById(R.id.control_toggle_switch);
    switchView.setId(toggleId);
    switchView.setChecked(isChecked);

    return switchLayout;
}
 
Example 13
Project: buildAPKsApps   File: ListSettingsLayout.java   View Source Code Vote up 5 votes
/**
   * removes setting view and its delimiter from a parent
   * @param layout
   * @param layoutIndex
   * @param settingView
   */
  private void safelyRemoveViewFromParent(LinearLayout layout, int layoutIndex, View settingView) {
  	LinearLayout parent = (LinearLayout) settingView.getParent();
if (parent != null) { 
	View delimiter = (View) settingView.getTag();
	parent.removeView(settingView);
	parent.removeView(delimiter);
}
  }
 
Example 14
Project: encdroidMC   File: FillTask.java   View Source Code Vote up 5 votes
@Override
protected void onPreExecute() {
	try {//sometime it crash if the user refresh while the list is already being refreshed
		super.onPreExecute();

		// Replace the ListView with a ProgressBar
		mProgBar = new ProgressBar(volumeBrowserActivity, null,android.R.attr.progressBarStyleLarge);

		// Set the layout to fill the screen
		mListView = volumeBrowserActivity.getListView();
		mLayout = (LinearLayout) mListView.getParent();
		if (mLayout==null) return;
		mLayout.setGravity(Gravity.CENTER);
		mLayout.setLayoutParams(new FrameLayout.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

		// Set the ProgressBar in the center of the layout
		LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		layoutParams.gravity = Gravity.CENTER;
		mProgBar.setLayoutParams(layoutParams);

		// Replace the ListView with the ProgressBar
		mLayout.removeView(mListView);
		mLayout.addView(mProgBar);
		mProgBar.setVisibility(View.VISIBLE);
	} catch (Exception e){
		e.printStackTrace();
	}
}
 
Example 15
Project: sealtalk-android-master   File: MultiVideoCallActivity.java   View Source Code Vote up 5 votes
@Override
public void onRemoteUserLeft(String userId, RongCallCommon.CallDisconnectedReason reason) {
    //incoming状态,localViewUserId为空
    if (localViewUserId == null)
        return;
    if (localViewUserId.equals(userId)) {
        localViewContainer.removeAllViews();
        String currentUserId = RongIMClient.getInstance().getCurrentUserId();
        FrameLayout remoteVideoView = (FrameLayout) remoteViewContainer.findViewWithTag(currentUserId);
        localView = (SurfaceView) remoteVideoView.getChildAt(0);
        remoteVideoView.removeAllViews();
        localViewContainer.addView(localView);
        TextView topUserNameView = (TextView) topContainer.findViewById(R.id.rc_voip_user_name);
        topUserNameView.setTag(currentUserId + "name");
        UserInfo userInfo = RongContext.getInstance().getUserInfoFromCache(currentUserId);
        if (userInfo != null) {
            topUserNameView.setText(userInfo.getName());
        } else {
            topUserNameView.setText(currentUserId);
        }
        localViewUserId = currentUserId;
    }

    View singleRemoteView = remoteViewContainer.findViewWithTag(userId + "view");

    if (singleRemoteView == null)
        return;

    LinearLayout container = (LinearLayout) singleRemoteView.getParent();
    container.removeView(singleRemoteView);
    if (container.equals(remoteViewContainer2)) {
        if (remoteViewContainer1.getChildCount() > 0) {
            View childView = remoteViewContainer1.getChildAt(0);
            remoteViewContainer1.removeView(childView);
            remoteViewContainer2.addView(childView);
        }
    }
}
 
Example 16
Project: sealtalk-android-master   File: CallUserGridView.java   View Source Code Vote up 5 votes
public void removeChild(String childId) {
    int containerCount = linearLayout.getChildCount();

    LinearLayout lastContainer = null;
    List<LinearLayout> containerList = new ArrayList<>();
    for (int i = 0; i < containerCount; i++) {
        LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
        containerList.add(container);
    }
    for (LinearLayout resultContainer : containerList) {
        if (lastContainer == null) {
            LinearLayout child = (LinearLayout) resultContainer.findViewWithTag(childId);
            if (child != null) {
                resultContainer.removeView(child);
                if (resultContainer.getChildCount() == 0) {
                    linearLayout.removeView(resultContainer);
                    break;
                } else {
                    lastContainer = resultContainer;
                }
            }
        } else {
            View view = resultContainer.getChildAt(0);
            resultContainer.removeView(view);
            lastContainer.addView(view);
            if (resultContainer.getChildCount() == 0) {
                linearLayout.removeView(resultContainer);
                break;
            } else {
                lastContainer = resultContainer;
            }
        }
    }
}
 
Example 17
Project: Hillffair17   File: EditorView.java   View Source Code Vote up 4 votes
public EditorView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);


    inflater = LayoutInflater.from(context);

    allLayout = new LinearLayout(context);
    allLayout.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    addView(allLayout, layoutParams);

    onClickListener = new OnClickListener() {
        @Override
        public void onClick(View view) {
            allLayout.removeView(view);
        }
    };

    focusChangeListener = new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                lastEditText = (EditText) view;
            }
        }
    };

    keyListener = new OnKeyListener() {
        @Override
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getKeyCode() == KeyEvent.KEYCODE_DEL) {
                EditText editText = (EditText) view;
                onBackPress(editText);
            }
            return false;
        }
    };

    EditText e = createEditText("Title", dip2px(10));
    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    allLayout.addView(e, p);

    EditText content = createEditText("Enter Description or Insert Any Image.\nSize of Description should be less than 200", dip2px(10));
    LinearLayout.LayoutParams contentp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    allLayout.addView(content, contentp
    );
    lastEditText = content;

}
 
Example 18
Project: Nimbus   File: EditorView.java   View Source Code Vote up 4 votes
public EditorView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);


    inflater = LayoutInflater.from(context);

    allLayout = new LinearLayout(context);
    allLayout.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    addView(allLayout, layoutParams);

    onClickListener = new OnClickListener() {
        @Override
        public void onClick(View view) {
            allLayout.removeView(view);
        }
    };

    focusChangeListener = new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                lastEditText = (EditText) view;
            }
        }
    };

    keyListener = new OnKeyListener() {
        @Override
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getKeyCode() == KeyEvent.KEYCODE_DEL) {
                EditText editText = (EditText) view;
                onBackPress(editText);
            }
            return false;
        }
    };

    EditText e = createEditText("Title", dip2px(10));
    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    allLayout.addView(e, p);

    EditText content = createEditText("Enter Description or Insert Any Image", dip2px(10));
    LinearLayout.LayoutParams contentp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    allLayout.addView(content, contentp
    );
    lastEditText = content;

}
 
Example 19
Project: buildAPKsApps   File: ListSettingsLayout.java   View Source Code Vote up 4 votes
public void updateLayout(Activity activity) {
	
	final LayoutInflater inflater = activity.getLayoutInflater();
	final ArrayList<Setting> settings = mApp.getSettings();
	final int settingCount = getSettingsCount(settings);
	final LinearLayout layout = mList;

	// Go through all settings and ensure they have corresponding 
	// views in the layout. Then remove not used views in such.
	
	for (int settingIndex = 0; settingIndex < settingCount; settingIndex++) {

		int layoutIndex = settingIndex << 1;
		View layoutView = layout.getChildCount() < layoutIndex ? null : layout.getChildAt(layoutIndex);

		Setting setting = settings.get(settingIndex + 1);
		View settingView = setting.getAssignedRenderer().getView(inflater, setting, null, activity);
		
		if (layoutView == null) {
			// we just need to append setting view

			safelyRemoveViewFromParent(layout, layoutIndex, settingView);

    		// add setting view
    		layout.addView(settingView);
    		
			// add delimiter if it is not the last setting
			ImageView delimiter = new ImageView(activity);
			delimiter.setImageResource(android.R.drawable.divider_horizontal_dim_dark);
			layout.addView(delimiter);
			settingView.setTag(delimiter);
			
		} else if (layoutView != settingView) {
			
			// we just need to remove current view and put setting view instead
			// replace view
			layout.removeView(layoutView);

    		// detach it from a parent if there is a parent
			safelyRemoveViewFromParent(layout, layoutIndex, settingView);
			
			layout.addView(settingView, layoutIndex); // add setting view
			settingView.setTag(layout.getChildAt(layoutIndex + 1)); // reuse delimiter
		} 
		// else - do nothing, this is same view
		
	}
	
	// if we have more views then settings, we have to remove redundant views
	final int layoutCount = layout.getChildCount();
	final int expectedCount = settingCount << 1;
	if (layoutCount > expectedCount) {
		layout.removeViews(expectedCount, layoutCount - expectedCount);
	}
}
 
Example 20
Project: mapbook-android   File: MapFragment.java   View Source Code Vote up 4 votes
private void replaceView(final LinearLayout mainView, final View oldView, final View newView){
  mainView.removeView(oldView);
  mainView.addView(newView);
}