Example usage for android.widget LinearLayout removeView

List of usage examples for android.widget LinearLayout removeView

Introduction

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

Prototype

@Override
public void removeView(View view) 

Source Link

Document

Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.

Usage

From source file:ru.tinkoff.acquiring.sdk.EnterCardFragment.java

private void resolveButtonAndIconsPosition(View root) {
    LinearLayout containerLayout = (LinearLayout) root.findViewById(R.id.ll_container_layout);
    View buttons = root.findViewById(R.id.pay_buttons_layout);
    View space = root.findViewById(R.id.space);
    View secureIcons = root.findViewById(R.id.iv_secure_icons);
    switch (buttonAndIconsPositionMode) {
    case BUTTON_UNDER_FIELDS_ICONS_ON_BOTTOM:
        break;/*from  w w  w  .ja v a 2  s  .co m*/
    case ICONS_ON_BOTTOM_BUTTON_UNDER_ICONS:
        containerLayout.removeView(buttons);
        containerLayout.addView(buttons);
        break;
    case ICONS_UNDER_FIELDS_BUTTON_ON_BOTTOM:
        containerLayout.removeView(secureIcons);
        removeSpace(containerLayout, space);
        containerLayout.removeView(buttons);
        containerLayout.addView(secureIcons);
        addSpace(containerLayout, space);
        containerLayout.addView(buttons);
        break;
    case ICONS_UNDER_FIELDS_BUTTON_UNDER_ICONS:
        containerLayout.removeView(secureIcons);
        removeSpace(containerLayout, space);
        containerLayout.removeView(buttons);
        containerLayout.addView(secureIcons);
        containerLayout.addView(buttons);
        break;
    case BUTTON_UNDER_FIELDS_ICONS_UNDER_BOTTOM:
        removeSpace(containerLayout, space);
        break;
    }
}

From source file:com.kaliturin.blacklist.fragments.SMSSendFragment.java

private boolean addRowToContactsList(@NonNull String number, @NonNull String name) {
    View view = getView();//from  w ww  .j  a  v a2 s . c o m
    if (view == null) {
        return false;
    }

    // add contact to the container
    if (!number2NameMap.containsKey(number)) {
        number2NameMap.put(number, name);
    } else {
        return false;
    }

    // create and add the new row
    final LinearLayout contactsViewList = (LinearLayout) view.findViewById(R.id.contacts_list);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View row = inflater.inflate(R.layout.row_sms_send_contact, contactsViewList, false);
    row.setTag(number);
    contactsViewList.addView(row);

    // init contact's info view
    String text = number;
    if (!name.isEmpty() && !name.equals(number)) {
        text = name + " (" + number + ")";
    }
    TextView textView = (TextView) row.findViewById(R.id.contact_number);
    textView.setText(text);

    // init button of removing
    ImageButton buttonRemove = (ImageButton) row.findViewById(R.id.button_remove);
    buttonRemove.setTag(row);
    buttonRemove.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            View row = (View) v.getTag();
            String number = (String) row.getTag();
            // remove contact from the container
            number2NameMap.remove(number);
            // remove row from the view-list
            contactsViewList.removeView(row);
        }
    });

    moveScroll();

    return true;
}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

private void showFlashRecoveryDialog() {
    final Dialog FlashRecoveryDialog = new Dialog(mContext);
    LayoutInflater inflater = getLayoutInflater();
    FlashRecoveryDialog.setTitle(R.string.flash_options);
    try {/*from w  w w . j ava2 s  .c o  m*/
        final ScrollView RecoveryLayout = (ScrollView) inflater.inflate(R.layout.recovery_dialog, null);
        LinearLayout layout = (LinearLayout) RecoveryLayout.getChildAt(0);

        FlashRecoveryDialog.setContentView(RecoveryLayout);
        if (!mDevice.isCwmSupported()) {
            layout.removeView(FlashRecoveryDialog.findViewById(R.id.bCWM));
        }
        if (!mDevice.isTwrpSupported()) {
            layout.removeView(FlashRecoveryDialog.findViewById(R.id.bTWRP));
        }
        if (!mDevice.isPhilzSupported()) {
            layout.removeView(FlashRecoveryDialog.findViewById(R.id.bPHILZ));
        }

        FlashRecoveryDialog.show();
    } catch (NullPointerException e) {
        Notifyer.showExceptionToast(mContext, TAG, e);
    }
}

From source file:com.moro.synapsemod.elements.STreeDescriptor.java

private void collapse() throws ElementFailureException {
    View v;//from w  ww .ja  v a  2s .com
    LinearLayout p;

    for (BaseElement e : baseElements) {
        if (e instanceof ActionValueClient) {
            if (ActionValueUpdater.isRegistered((ActionValueClient) e))
                ActionValueUpdater.removeElement((ActionValueClient) e);

            if (ActionValueUpdater.isPerpetual((ActionValueClient) e))
                ActionValueUpdater.removePerpetual((ActionValueClient) e);
        }

        if (e instanceof ActionValueNotifierClient) {
            ActionValueNotifierHandler.remove((ActionValueNotifierClient) e);
        }

        /*
         *  Trying to get a View of an child STreeDescriptor is not what we want to do here,
         *  and will cause undefined behaviour. A collapse will logically mean an invalidation
         *  of the whole tree, and getting a View of a child will cause a parsing of all
         *  of its elements, which will not be able to operate normally as the parent node
         *  will be invalid.
         */
        if (e instanceof STreeDescriptor)
            continue;

        v = e.getView();
        if (v != null) {
            p = (LinearLayout) v.getParent();
            if (p != null)
                p.removeView(v);
        }

        fragment.removeElement(e);
    }

    actionList.clear();
    baseElements.clear();
    descriptorList.clear();

    for (STreeDescriptor b : this.children)
        b.collapse();

    this.children.clear();
}

From source file:com.ezeeideas.wordjam.BaseGameActivity.java

/**
 * Set up Views that are common to all Games
 *//*w ww .ja va  2 s. c  om*/
protected void setupViews() {
    //Header
    TextView headerTextView = (TextView) findViewById(R.id.game_header_text_view);
    String headerText = String.format(getResources().getString(R.string.game_header),
            GameUtils.getPlayTypeName(mPlayType, this), mLevel);
    headerTextView.setText(headerText);

    //Game Name
    TextView gameHeadingTextView = (TextView) findViewById(R.id.game_title_text_view);
    String gameHeadingText = String.format(getResources().getString(R.string.game_heading),
            GameUtils.getGameNameFromGameType(mGameType, this), mGameNumber);
    gameHeadingTextView.setText(gameHeadingText);

    //Points Text
    mPointsTextView = (TextView) findViewById(R.id.game_points_text_view);
    int points = (mIsPlay ? mLevelPoints : mPracticePointsEarned);
    String pointsText = String.format(getResources().getString(R.string.game_points_label), points);
    mPointsTextView.setText(pointsText);

    //Timer Text
    mGameTimeTextView = (TextView) findViewById(R.id.game_time_text_view);
    mGameTimeTextView.setText(Utils.convertTime(mGameTime));

    //Buttons at the bottom
    mStopButton = (ImageButton) findViewById(R.id.stop_button);
    mStopButton.setOnClickListener(this);

    mPauseButton = (ImageButton) findViewById(R.id.pause_button);
    mPauseButton.setOnClickListener(this);

    mGiveUpButton = (ImageButton) findViewById(R.id.giveup_button);
    mGiveUpButton.setOnClickListener(this);

    mHintButton = (ImageButton) findViewById(R.id.hint_button);
    mHintButton.setOnClickListener(this);

    mHelpButton = (ImageButton) findViewById(R.id.help_button);
    mHelpButton.setOnClickListener(this);

    //mShareButton = (ImageButton) findViewById(R.id.share_button);
    //mShareButton.setOnClickListener(this);

    mPreviousButton = (ImageButton) findViewById(R.id.previous_button);
    mPreviousButton.setOnClickListener(this);
    if (mGameNumber == 1) //disable previous in case of first game
    {
        mPreviousButton.setEnabled(false);
    }
    if (!mIsPlay) //Practice games don't have a Previous button
    {
        LinearLayout buttonLayout = (LinearLayout) findViewById(R.id.game_button_layout);
        buttonLayout.removeView(mPreviousButton);
        //mPreviousButton.setVisibility(ImageButton.INVISIBLE);
        //TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 0f);
        //mPreviousButton.setLayoutParams(params);
    }

    mNextButton = (ImageButton) findViewById(R.id.next_button);
    mNextButton.setOnClickListener(this);

    //set up hint button with values, as required
    //setupHintButton();

    //set up the ads
    mBannerAdView = (AdView) findViewById(R.id.adView);
    mBannerAdView.setAdListener(this);

    //set up game specific views
    doSetupViews();
}

From source file:com.af.synapse.elements.STreeDescriptor.java

public void collapse() throws ElementFailureException {
    View v;//ww  w .  j  a va2s.  c  om
    LinearLayout p;

    for (BaseElement e : baseElements) {
        if (e instanceof ActionValueClient) {
            if (ActionValueUpdater.isRegistered((ActionValueClient) e))
                ActionValueUpdater.removeElement((ActionValueClient) e);

            if (ActionValueUpdater.isPerpetual((ActionValueClient) e))
                ActionValueUpdater.removePerpetual((ActionValueClient) e);
        }

        if (e instanceof ActionValueNotifierClient) {
            ActionValueNotifierHandler.remove((ActionValueNotifierClient) e);
        }

        /*
         *  Trying to get a View of an child STreeDescriptor is not what we want to do here,
         *  and will cause undefined behaviour. A collapse will logically mean an invalidation
         *  of the whole tree, and getting a View of a child will cause a parsing of all
         *  of its elements, which will not be able to operate normally as the parent node
         *  will be invalid.
         */
        if (e instanceof STreeDescriptor)
            continue;

        v = e.getView();
        if (v != null) {
            p = (LinearLayout) v.getParent();
            if (p != null)
                p.removeView(v);
        }

        fragment.removeElement(e);
    }

    actionList.clear();
    baseElements.clear();
    descriptorList.clear();

    for (STreeDescriptor b : this.children)
        b.collapse();

    this.children.clear();
}

From source file:mroza.forms.ChooseProgramActivity.java

private void enableShowAllButton(boolean enable) {
    LinearLayout layout = (LinearLayout) findViewById(R.id.LayoutGrid);
    Button button = (Button) findViewById(R.id.show_all_programs_button_id);

    if (enable && button == null) {
        button = new Button(this);
        button.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        button.setText(R.string.show_all_programs);
        button.setId(R.id.show_all_programs_button_id);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                List<ChildTable> childTables;
                clearFilters(true);/*  w  ww . j av a2 s  .  c  o  m*/
                clearSearchField();

                Term selectedTerm = getSelectedTerm();
                childTables = ChildTablesRepository.getChildTableByTerm(ChooseProgramActivity.this,
                        selectedTerm, child);
                handleListViewBehavior(childTables, selectedTerm);

                enableShowAllButton(false);
            }
        });
        layout.addView(button, 1);
    } else if (!enable && button != null) {
        layout.removeView(button);
    }
}

From source file:com.android.calendar.event.EditEventView.java

@Override
public void onClick(View view) {
    if (view == mRruleButton) {
        Bundle b = new Bundle();
        b.putLong(RecurrencePickerDialog.BUNDLE_START_TIME_MILLIS, mStartTime.toMillis(false));
        b.putString(RecurrencePickerDialog.BUNDLE_TIME_ZONE, mStartTime.timezone);

        // TODO may be more efficient to serialize and pass in
        // EventRecurrence
        b.putString(RecurrencePickerDialog.BUNDLE_RRULE, mRrule);

        FragmentManager fm = mActivity.getSupportFragmentManager();
        RecurrencePickerDialog rpd = (RecurrencePickerDialog) fm.findFragmentByTag(FRAG_TAG_RECUR_PICKER);
        if (rpd != null) {
            rpd.dismiss();/*  w ww .  ja v a  2  s  .co  m*/
        }
        rpd = new RecurrencePickerDialog();
        rpd.setArguments(b);
        rpd.setOnRecurrenceSetListener(EditEventView.this);
        rpd.show(fm, FRAG_TAG_RECUR_PICKER);
        return;
    }

    // This must be a click on one of the "remove reminder" buttons
    LinearLayout reminderItem = (LinearLayout) view.getParent();
    LinearLayout parent = (LinearLayout) reminderItem.getParent();
    parent.removeView(reminderItem);
    mReminderItems.remove(reminderItem);
    updateRemindersVisibility(mReminderItems.size());
    EventViewUtils.updateAddReminderButton(mView, mReminderItems, mModel.mCalendarMaxReminders);
}

From source file:com.t2.compassionMeditation.Graphs1Activity.java

/**
 * Sets up all parameters for display of both the chart on the screen 
 * AND a color coded display of the parameters and their values 
 *///from  www  . j a  v  a 2 s. co m
private void generateChart() {
    // Set up chart
    XYMultipleSeriesDataset deviceDataset = new XYMultipleSeriesDataset();
    XYMultipleSeriesRenderer deviceRenderer = new XYMultipleSeriesRenderer();

    LinearLayout layout = (LinearLayout) findViewById(R.id.deviceChart);
    if (mDeviceChartView != null) {
        layout.removeView(mDeviceChartView);
    }
    if (true) {
        mDeviceChartView = ChartFactory.getLineChartView(this, deviceDataset, deviceRenderer);
        mDeviceChartView.setBackgroundColor(Color.BLACK);
        layout.addView(mDeviceChartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    }

    deviceRenderer.setShowLabels(false);
    deviceRenderer.setMargins(new int[] { 0, 5, 5, 0 });
    deviceRenderer.setShowAxes(true);
    deviceRenderer.setShowLegend(false);

    deviceRenderer.setZoomEnabled(false, false);
    deviceRenderer.setPanEnabled(false, false);
    deviceRenderer.setYAxisMin(0);
    deviceRenderer.setYAxisMax(100);

    SpannableStringBuilder sMeasuresText = new SpannableStringBuilder("Displaying: ");

    ArrayList<Long> visibleIds = getVisibleIds(KEY_NAME);

    int keyCount = mBioParameters.size();
    keyCount = mBioParameters.size();

    int lineNum = 0;
    for (int i = 0; i < mBioParameters.size(); ++i) {
        GraphBioParameter item = mBioParameters.get(i);

        item.visible = visibleIds.contains(item.id);
        if (!item.visible) {
            continue;
        }

        deviceDataset.addSeries(item.series);
        item.color = getKeyColor(i, keyCount);

        // Add name of the measure to the displayed text field
        ForegroundColorSpan fcs = new ForegroundColorSpan(item.color);
        int start = sMeasuresText.length();
        sMeasuresText.append(mBioParameters.get(i).title1 + ", ");
        int end = sMeasuresText.length();
        sMeasuresText.setSpan(fcs, start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
        if (sMeasuresText.length() > 40 && lineNum == 0) {
            lineNum++;
        }

        XYSeriesRenderer seriesRenderer = new XYSeriesRenderer();
        seriesRenderer.setColor(item.color);
        seriesRenderer.setPointStyle(PointStyle.CIRCLE);

        deviceRenderer.addSeriesRenderer(seriesRenderer);
    }

    mMeasuresDisplayText.setText(sMeasuresText);
}

From source file:com.todoroo.astrid.activity.TaskListFragment.java

private void showFeedbackPrompt() {
    if (!(this instanceof TagViewFragment)
            && (DateUtilities.now() - Preferences.getLong(PREF_LAST_FEEDBACK_TIME, 0)) > FEEDBACK_TIME_INTERVAL
            && taskService.getUserActivationStatus()) {
        final LinearLayout root = (LinearLayout) getView().findViewById(R.id.taskListParent);
        if (root.findViewById(R.id.feedback_banner) == null) {
            final View feedbackPrompt = getActivity().getLayoutInflater().inflate(R.layout.feedback_prompt,
                    root, false);//from w  w w .  j av  a2 s.  c  om

            feedbackPrompt.findViewById(R.id.positiveFeedback).setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        root.removeView(feedbackPrompt);
                        FeedbackPromptDialogs.showFeedbackDialog((AstridActivity) getActivity(), true);
                        Preferences.setLong(PREF_LAST_FEEDBACK_TIME, DateUtilities.now());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });

            feedbackPrompt.findViewById(R.id.negativeFeedback).setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        root.removeView(feedbackPrompt);
                        FeedbackPromptDialogs.showFeedbackDialog((AstridActivity) getActivity(), false);
                        Preferences.setLong(PREF_LAST_FEEDBACK_TIME, DateUtilities.now());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });

            root.addView(feedbackPrompt, 0);
        }
    }
}