Example usage for android.view ViewGroup removeAllViews

List of usage examples for android.view ViewGroup removeAllViews

Introduction

In this page you can find the example usage for android.view ViewGroup removeAllViews.

Prototype

public void removeAllViews() 

Source Link

Document

Call this method to remove all child views from the ViewGroup.

Usage

From source file:com.itude.mobile.mobbl.core.controller.util.MBBasicViewController.java

/**
 * Looks up the {@link MBPage} associated with this instance and sets the view property with a fresh view hierarchy constructed from the page definition.
 * /*from w ww.j  av  a2  s .  co m*/
 * @param contentViewNeedsToBeSet boolean indicating if the content view needs to be set during rebuild
 */
public void rebuildView(final boolean contentViewNeedsToBeSet) {
    // it is possible for the fragment to get detached in the meantime,
    // so cache the activity
    final Activity activity = getActivity();
    if (activity == null)
        return;
    MBPage page = getPage();
    page.rebuildView();

    MBThread runnable = new MBThread(page) {
        @Override
        public void runMethod() {
            if (contentViewNeedsToBeSet) {
                ViewGroup fragmentContainer = (ViewGroup) getView();

                if (fragmentContainer != null) {
                    fragmentContainer.removeAllViews();

                    ViewGroup view = buildInitialView(LayoutInflater.from(activity));

                    fragmentContainer.addView(view);
                    _contentView = view;
                } else
                    Log.w(Constants.APPLICATION_NAME, "Failed to refresh view for page "
                            + getPage().getPageName() + ", has the activity been created?");
            }
        }
    };
    activity.runOnUiThread(runnable);
}

From source file:android.support.v7.app.ActionBarActivityDelegateBase.java

@Override
public void setContentView(View v) {
    ensureSubDecor();/*from ww w.  j  av a 2 s.  c  o  m*/
    if (mHasActionBar) {
        final ViewGroup contentParent = (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content);
        contentParent.removeAllViews();
        contentParent.addView(v);
    } else {
        mActivity.superSetContentView(v);
    }
}

From source file:android.support.v7.app.ActionBarActivityDelegateBase.java

@Override
public void setContentView(View v, ViewGroup.LayoutParams lp) {
    ensureSubDecor();//  ww  w.ja va2s.c  o  m
    if (mHasActionBar) {
        final ViewGroup contentParent = (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content);
        contentParent.removeAllViews();
        contentParent.addView(v, lp);
    } else {
        mActivity.superSetContentView(v, lp);
    }
}

From source file:android.support.v7.app.ActionBarActivityDelegateBase.java

@Override
public void setContentView(int resId) {
    ensureSubDecor();// w  ww .j ava 2 s  .c  o m
    if (mHasActionBar) {
        final ViewGroup contentParent = (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content);
        contentParent.removeAllViews();
        final LayoutInflater inflater = LayoutInflater.from(mActivity);
        inflater.inflate(resId, contentParent);
    } else {
        mActivity.superSetContentView(resId);
    }
}

From source file:li.klass.fhem.fragments.ConnectionDetailFragment.java

@SuppressLint("InflateParams")
private void handleConnectionTypeChange(ServerType connectionType) {
    if (getView() == null)
        return;/*from  w w w  .  j  ava2 s. co  m*/

    this.connectionType = checkNotNull(connectionType);
    FragmentActivity activity = checkNotNull(getActivity());
    LayoutInflater inflater = checkNotNull(activity.getLayoutInflater());

    View view;
    if (connectionType == ServerType.FHEMWEB) {
        view = inflater.inflate(R.layout.connection_fhemweb, null);
        handleFHEMWEBView(view);
    } else if (connectionType == ServerType.TELNET) {
        view = inflater.inflate(R.layout.connection_telnet, null);
    } else {
        throw new IllegalArgumentException("cannot handle connection type " + connectionType);
    }

    assert view != null;

    CheckBox showPasswordCheckbox = (CheckBox) view.findViewById(R.id.showPasswordCheckbox);
    final EditText passwordView = (EditText) view.findViewById(R.id.password);
    if (showPasswordCheckbox != null && passwordView != null) {
        showPasswordCheckbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CheckBox radio = (CheckBox) view;
                boolean checked = radio.isChecked();
                if (checked) {
                    passwordView.setTransformationMethod(null);
                } else {
                    passwordView.setTransformationMethod(PasswordTransformationMethod.getInstance());
                }
            }
        });

        if (isModify)
            showPasswordCheckbox.setEnabled(false);
    }

    CheckBox showCertificatePasswordCheckbox = (CheckBox) view
            .findViewById(R.id.showCertificatePasswordCheckbox);
    final EditText passwordClientCertificateView = (EditText) view.findViewById(R.id.clientCertificatePassword);
    if (showCertificatePasswordCheckbox != null && passwordClientCertificateView != null) {
        showCertificatePasswordCheckbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CheckBox radio = (CheckBox) view;
                boolean checked = radio.isChecked();
                if (checked) {
                    passwordClientCertificateView.setTransformationMethod(null);
                } else {
                    passwordClientCertificateView
                            .setTransformationMethod(PasswordTransformationMethod.getInstance());
                }
            }
        });

        if (isModify)
            showCertificatePasswordCheckbox.setEnabled(false);
    }

    ViewGroup connectionPreferences = (ViewGroup) checkNotNull(getView())
            .findViewById(R.id.connectionPreferences);
    checkNotNull(connectionPreferences);
    connectionPreferences.removeAllViews();
    connectionPreferences.addView(view);

    if (detailChangedListener != null)
        detailChangedListener.onChanged();
}

From source file:com.cypress.cysmart.RDKEmulatorView.RemoteControlEmulatorFragment.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        LayoutInflater inflater = (LayoutInflater) getActivity()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mParentView = inflater.inflate(R.layout.rgb_view_landscape, null);
        ViewGroup rootViewG = (ViewGroup) getView();
        // Remove all the existing views from the root view.
        try {/*w w w .j  a va  2  s  .com*/
            assert rootViewG != null;
            rootViewG.removeAllViews();
            rootViewG.addView(mParentView);
        } catch (Exception e) {
            e.printStackTrace();
        }

    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        LayoutInflater inflater = (LayoutInflater) getActivity()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mParentView = inflater.inflate(R.layout.rgb_view_portrait, null);
        ViewGroup rootViewG = (ViewGroup) getView();
        // Remove all the existing views from the root view.
        try {
            assert rootViewG != null;
            rootViewG.removeAllViews();
            rootViewG.addView(mParentView);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

From source file:cs.umass.edu.prepare.view.activities.CalendarActivity.java

/**
 * Updates the details view for a particular date.
 * @param dateKey corresponds to the selected date. Note that the date key must have zeroed
 *                out all fields excluding month, year and date.
 *//*from   ww w  . j a  v  a  2 s.c  o m*/
private void updateDetails(Calendar dateKey) {
    TextView txtDate = (TextView) findViewById(R.id.txtDate);
    txtDate.setText(dayFormat.format(selectedDate.getTime()) + "\n"
            + selectedDate.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()));

    ViewGroup insertPoint = (ViewGroup) findViewById(R.id.details);
    insertPoint.removeAllViews();

    if (adherenceData == null) {
        Log.w(TAG, "Warning : No adherence data found.");
    } else {
        if (adherenceData.containsKey(dateKey))
            insertDetailsForDate(dateKey, insertPoint);
    }
}

From source file:pl.edu.agh.schedule.ui.BaseActivity.java

private void createNavDrawerItems() {
    ViewGroup mDrawerItemsListContainer = (ViewGroup) findViewById(R.id.navdrawer_items_list);
    if (mDrawerItemsListContainer == null) {
        return;/*  w w w . j  a va2s.  c o  m*/
    }

    mNavDrawerItemViews = new View[mNavDrawerItems.size()];
    mDrawerItemsListContainer.removeAllViews();
    int i = 0;
    for (int itemId : mNavDrawerItems) {
        mNavDrawerItemViews[i] = makeNavDrawerItem(itemId, mDrawerItemsListContainer);
        mDrawerItemsListContainer.addView(mNavDrawerItemViews[i]);
        ++i;
    }
}

From source file:br.com.bioscada.apps.biotracks.fragments.ChartFragment.java

@Override
public void onStart() {
    super.onStart();
    ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layout.removeAllViews();
    layout.addView(chartView, layoutParams);
}

From source file:org.digitalcampus.oppia.widgets.QuizWidget.java

public void loadQuiz() {
    if (this.quiz == null) {
        this.quiz = new Quiz();
        this.quiz.load(quizContent,
                prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage()));
    }/*w ww  .j a  v  a  2 s. c o  m*/
    if (this.isOnResultsPage) {
        this.showResults();
    } else {
        // determine availability
        if (this.quiz.getAvailability() == Quiz.AVAILABILITY_ALWAYS) {
            this.showQuestion();
        } else if (this.quiz.getAvailability() == Quiz.AVAILABILITY_SECTION) {

            // check to see if all previous section activities have been completed
            DbHelper db = new DbHelper(getView().getContext());
            long userId = db.getUserId(prefs.getString(PrefsActivity.PREF_USER_NAME, ""));
            boolean completed = db.isPreviousSectionActivitiesCompleted(course, activity, userId);
            DatabaseManager.getInstance().closeDatabase();

            if (completed) {
                this.showQuestion();
            } else {
                ViewGroup vg = (ViewGroup) getView().findViewById(activity.getActId());
                vg.removeAllViews();
                vg.addView(View.inflate(getView().getContext(), R.layout.widget_quiz_unavailable, null));

                TextView tv = (TextView) getView().findViewById(R.id.quiz_unavailable);
                tv.setText(R.string.widget_quiz_unavailable_section);
            }
        } else if (this.quiz.getAvailability() == Quiz.AVAILABILITY_COURSE) {
            // check to see if all previous course activities have been completed
            DbHelper db = new DbHelper(getView().getContext());
            long userId = db.getUserId(prefs.getString(PrefsActivity.PREF_USER_NAME, ""));
            boolean completed = db.isPreviousCourseActivitiesCompleted(course, activity, userId);
            DatabaseManager.getInstance().closeDatabase();

            if (completed) {
                this.showQuestion();
            } else {
                ViewGroup vg = (ViewGroup) getView().findViewById(activity.getActId());
                vg.removeAllViews();
                vg.addView(View.inflate(getView().getContext(), R.layout.widget_quiz_unavailable, null));

                TextView tv = (TextView) getView().findViewById(R.id.quiz_unavailable);
                tv.setText(R.string.widget_quiz_unavailable_course);
            }
        }
    }
}