Example usage for android.widget LinearLayout removeAllViews

List of usage examples for android.widget LinearLayout removeAllViews

Introduction

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

Prototype

public void removeAllViews() 

Source Link

Document

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

Usage

From source file:com.dmbstream.android.util.Util.java

/**
 * Resolves the default text color for notifications.
 *
 * Based on http://stackoverflow.com/questions/4867338/custom-notification-layouts-and-text-colors/7320604#7320604
 *///from   ww  w. j a  v  a  2s .c  om
private static Pair<Integer, Integer> getNotificationTextColors(Context context) {
    if (NOTIFICATION_TEXT_COLORS.getFirst() == null && NOTIFICATION_TEXT_COLORS.getSecond() == null) {
        try {
            Notification notification = new Notification();
            String title = "title";
            String content = "content";
            notification.setLatestEventInfo(context, title, content, null);
            LinearLayout group = new LinearLayout(context);
            ViewGroup event = (ViewGroup) notification.contentView.apply(context, group);
            findNotificationTextColors(event, title, content);
            group.removeAllViews();
        } catch (Exception x) {
            Log.w(TAG, "Failed to resolve notification text colors.", x);
        }
    }
    return NOTIFICATION_TEXT_COLORS;
}

From source file:com.seraphim.chips.ChipsVerticalLinearLayout.java

private void clearChipsViews() {
    for (LinearLayout linearLayout : lineLayouts) {
        linearLayout.removeAllViews();
    }/*from www . ja v  a  2 s  . co  m*/
    lineLayouts.clear();
    removeAllViews();
}

From source file:eu.liveGov.libraries.livegovtoolkit.activities_fragments.QuestionaireResultFragment.java

@Override
public void onDestroyView() {
    super.onDestroyView();
    LinearLayout layout = (LinearLayout) getActivity().findViewById(R.id.questionaire_response_fragment);
    if (layout != null) {
        layout.removeAllViews();
    }/*w ww  .  ja  v  a 2 s .c  o m*/
}

From source file:hu.balazsbakai.sq.ui.fragments.FragmentAddPublicServers.java

@Override
public void onResume() {
    super.onResume();
    actionBarTitleTextView.setText(getString(R.string.addPublicServers));
    viewPager = (ViewPager) getActivity().findViewById(R.id.viewpager);
    viewPager.setVisibility(View.INVISIBLE);

    listView = (ListView) getActivity().findViewById(R.id.listViewA);
    listView.setEmptyView(getActivity().findViewById(R.id.empty_addpublicservers_view));
    listView.setAdapter(new AddPublicServersAdapter(getActivity()));

    if (listView.getAdapter().getCount() == 0) {
        LinearLayout ll = (LinearLayout) getActivity().findViewById(R.id.addButtonLayout);
        ll.removeAllViews();
    }//from   w  w  w  .j a  v  a2s .com

}

From source file:com.fullmeadalchemist.mustwatch.ui.recipe.detail.RecipeDetailFragment.java

private void updateRecipeIngredientUiInfo() {
    if (viewModel.recipe.ingredients != null) {
        // FIXME: this is not performant and looks ghetto.
        Timber.d("Found %s BatchIngredients for this Recipe; adding them to the ingredientsList",
                viewModel.recipe.ingredients.size());
        LinearLayout ingredientsList = getActivity().findViewById(R.id.ingredients_list);
        ingredientsList.removeAllViews();
        for (BatchIngredient ingredient : viewModel.recipe.ingredients) {
            BatchIngredientView ingredientText = new BatchIngredientView(getActivity());
            ingredientText.setBatchIngredient(ingredient);
            ingredientsList.addView(ingredientText);
        }/*  w  ww. java2 s .  c  om*/
    } else {
        Timber.d("No Ingredients found for this Recipe.");
    }
}

From source file:eu.liveGov.libraries.livegovtoolkit.activities_fragments.UserInformationQuestionaireFragment.java

@Override
public void onDestroyView() {
    super.onDestroyView();
    if (_questionaireView != null)
        _questionaireView.removeListener(this);

    LinearLayout layout = (LinearLayout) getActivity().findViewById(R.id.questionaire_fragment);
    if (layout != null)
        layout.removeAllViews();
}

From source file:com.microsoft.mimickeralarm.settings.RepeatingDaysPreference.java

@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    LinearLayout container = (LinearLayout) holder.findViewById(R.id.pref_repeating_container);
    container.removeAllViews();
    for (int i = 0; i < mRepeatingDays.length; i++) {
        DayView dayView = new DayView(getContext(), this, i);
        dayView.setText(mDayNames[i]);/*w  w w.  ja  v a  2s. c o  m*/
        dayView.setRepeating(mRepeatingDays[i]);
        container.addView(dayView);
    }
    super.onBindViewHolder(holder);
}

From source file:org.alfresco.mobile.android.application.fragments.account.AccountsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setRootView(inflater.inflate(R.layout.fr_accounts, container, false));

    // Accounts//from  w  w w.  jav  a 2  s  .c  om
    List<AlfrescoAccount> accounts = AlfrescoAccountManager.retrieveAccounts(getActivity());
    View accountView;
    LinearLayout accountContainer = (LinearLayout) viewById(R.id.settings_accounts_container);
    accountContainer.removeAllViews();
    TwoLinesViewHolder vh;
    for (AlfrescoAccount account : accounts) {
        accountView = LayoutInflater.from(getActivity()).inflate(R.layout.row_two_lines_borderless_rounded,
                accountContainer, false);
        accountView.setTag(account.getId());
        vh = HolderUtils.configure(accountView, account.getUsername(), account.getTitle(),
                R.drawable.ic_account_circle_grey);
        AccountsAdapter.displayAvatar(getActivity(), account, R.drawable.ic_account_light, vh.icon);

        vh.choose.setVisibility(View.GONE);

        accountView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (getActivity() instanceof PublicDispatcherActivity) {
                    AlfrescoAccount selectedAccount = AlfrescoAccountManager.getInstance(getActivity())
                            .retrieveAccount((Long) v.getTag());
                    ((PublicDispatcherActivity) getActivity()).managePublicIntent(selectedAccount);
                }
            }
        });
        accountContainer.addView(accountView);
    }

    return getRootView();
}

From source file:eu.liveGov.libraries.livegovtoolkit.activities_fragments.QuestionaireFragment.java

@Override
public void onDestroyView() {
    super.onDestroyView();
    if (_questionaireView != null) {
        _questionaireView.removeListener(this);
    }//from  ww w  .j  av a2 s .c  om
    LinearLayout layout = (LinearLayout) getActivity().findViewById(R.id.questionaire_fragment);
    if (layout != null) {
        layout.removeAllViews();
    }
}

From source file:cn.count.easydrive366.CarRegistrationActivity.java

@Override
protected void initView() {
    try {/*w  ww .  j av  a  2 s.c o  m*/
        //check_date
        //((TextView)findViewById(R.id.txt_carregistration_brand)).setText(_result.getString("brand"));
        ((TextView) findViewById(R.id.txt_carregistration_check_date)).setText(_result.getString("check_date"));
        ((TextView) findViewById(R.id.txt_carregistration_car_typename))
                .setText(_result.getString("car_typename"));
        ((TextView) findViewById(R.id.txt_carregistration_engine_no)).setText(_result.getString("engine_no"));
        //((TextView)findViewById(R.id.txt_carregistration_issue_date  )).setText(_result.getString("issue_date"));
        ((TextView) findViewById(R.id.txt_carregistration_model)).setText(_result.getString("model"));
        ((TextView) findViewById(R.id.txt_carregistration_plate_no)).setText(_result.getString("plate_no"));
        ((TextView) findViewById(R.id.txt_carregistration_registration_date))
                .setText(_result.getString("registration_date"));
        ((TextView) findViewById(R.id.txt_carregistration_untreated_fine))
                .setText(_result.getString("untreated_fine"));
        ((TextView) findViewById(R.id.txt_carregistration_untreated_mark))
                .setText(_result.getString("untreated_mark"));
        ((TextView) findViewById(R.id.txt_carregistration_untreated_number))
                .setText(_result.getString("untreated_number"));
        ((TextView) findViewById(R.id.txt_carregistration_vin)).setText(_result.getString("vin"));
        ((TextView) findViewById(R.id.txt_carregistration_owner_name)).setText(_result.getString("owner_name"));
        ((TextView) findViewById(R.id.txt_carregistration_owner_license))
                .setText(_result.getString("owner_license"));
        this.setupRightButton();
        /*
        ((Button)findViewById(R.id.btn_carregistration_edit)).setOnClickListener(new OnClickListener(){
                
           @Override
           public void onClick(View v) {
              Intent intent = new Intent(CarRegistrationActivity.this,CarRegistrationEditActivity.class);
              intent.putExtra("data", _result.toString());
              startActivityForResult(intent,0);
                      
           }});
           */
        ((Button) findViewById(R.id.btn_carregistration_search)).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(CarRegistrationActivity.this, ViolationSearchActivity.class);
                //intent.putExtra("data", _result.toString());
                startActivityForResult(intent, 1);

            }
        });
        LinearLayout items = (LinearLayout) findViewById(R.id.layout_shops);
        items.removeAllViews();
        for (int i = 0; i < _shops.length(); i++) {
            JSONObject obj = _shops.getJSONObject(i);
            CarShopItem item = new CarShopItem(this, null, obj.getString("name"),
                    String.format("%s(%s)", obj.getString("address"), obj.get("phone")));
            item.setTag(obj.getString("url"));
            item.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    String url = (String) v.getTag();
                    if (url != null && !url.isEmpty()) {
                        Intent intent = new Intent(CarRegistrationActivity.this, BrowserActivity.class);
                        intent.putExtra("url", url);
                        CarRegistrationActivity.this.startActivity(intent);

                    }

                }
            });
            items.addView(item);
        }
        this.endRefresh();
    } catch (Exception e) {
        log(e);
    }

}