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:org.montanafoodhub.app.producer.ProducerDetailFragment.java

private void loadCertifications(View view) {

    LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.certificationLayout);
    linearLayout.removeAllViews();

    ImageCache imageCache = ((HubApplication) getActivity().getApplication()).getImageCache();

    for (Certification cert : _producer.getCertifications()) {
        RelativeLayout relativeLayout = (RelativeLayout) LayoutInflater.from(getActivity())
                .inflate(R.layout.certification, null);
        relativeLayout.setOnClickListener(this);
        relativeLayout.setTag(cert);/*from   w w w.  j  a va2 s . c  om*/

        ImageView imageView = (ImageView) relativeLayout.findViewById(R.id.certificationImageview);
        imageCache.loadImage(imageView, cert.getIconUrl(), R.drawable.default_certification);

        TextView textView = (TextView) relativeLayout.findViewById(R.id.certificationText);
        textView.setText(cert.getDisplayName());

        linearLayout.addView(relativeLayout);
    }
}

From source file:com.fullmeadalchemist.mustwatch.ui.batch.detail.BatchDetailFragment.java

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

From source file:uk.ac.horizon.aestheticodes.activities.ExperienceEditActivity.java

public void updateMarkers() {
    final LinearLayout markerList = (LinearLayout) findViewById(R.id.markerList);
    markerList.removeAllViews();
    final List<Marker> markers = new ArrayList<>(experience.getMarkers().values());
    Collections.sort(markers, new Comparator<Marker>() {
        @Override/*www  .  ja va 2s .  co  m*/
        public int compare(Marker markerAction, Marker markerAction2) {
            return markerAction.getCode().compareTo(markerAction2.getCode());
        }
    });
    LayoutInflater inflater = getLayoutInflater();
    for (final Marker marker : markers) {
        View view = inflater.inflate(R.layout.marker_listitem, markerList, false);
        Properties markerProperties = new Properties(this, marker, view);
        markerProperties.get("code").bindTo(R.id.markerCode);
        markerProperties.get("action").formatAs(new URLFormat()).bindTo(R.id.markerAction);
        markerProperties.load();
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogFragment newFragment = new MarkerEditDialog();
                Bundle bundle = new Bundle();
                bundle.putString("code", marker.getCode());
                newFragment.setArguments(bundle);
                newFragment.show(getSupportFragmentManager(), "marker.edit");
            }
        });
        markerList.addView(view);
    }
}

From source file:org.arasthel.almeribus.fragments.InfoParadaFragment.java

public void calcularTiempos() {
    ImageView refrescar = (ImageView) content.findViewById(R.id.refrescar);
    refrescar.setImageResource(R.drawable.ic_menu_refresh_disabled);
    refrescar.setOnClickListener(null);/*from  w w w  .j  av  a  2 s .c  o m*/
    LinearLayout listaTiempos = (LinearLayout) content.findViewById(R.id.tiemposEspera);
    listaTiempos.removeAllViews();
    View progress = content.findViewById(R.id.progress);
    progress.setVisibility(View.VISIBLE);
    for (int numLinea : mLineas) {
        //new CalcularTiempoParada(mNumParada, numLinea, content).execute(getActivity());
        mostrarLinea(numLinea, mNumParada);
    }
}

From source file:se.tmeit.app.ui.members.MemberInfoFragment.java

private void initializeListOfBadges(LinearLayout layout, List<MemberBadge> badges) {
    layout.removeAllViews();

    Picasso picasso = new Picasso.Builder(getContext())
            .downloader(new OkHttp3Downloader(TmeitHttpClient.getInstance())).build();

    LayoutInflater layoutInflater = getActivity().getLayoutInflater();
    for (MemberBadge badge : badges) {
        View view = layoutInflater.inflate(R.layout.list_item_member_badge, layout, false);

        TextView titleText = (TextView) view.findViewById(R.id.badge_title);
        titleText.setText(badge.title());

        ImageView imageView = (ImageView) view.findViewById(R.id.badge_image);
        picasso.load(Uri.parse(TmeitServiceConfig.ROOT_URL_INSECURE).buildUpon().path(badge.src()).build())
                .resizeDimen(R.dimen.tmeit_member_badge_size, R.dimen.tmeit_member_badge_size).centerInside()
                .into(imageView);//from   w w w. ja va  2 s.co m

        layout.addView(view);
    }
}

From source file:com.handlerexploit.news.fragments.WeatherFragment.java

private void render(WeatherInfo weatherInfo) {
    Activity activity = getActivity();/*  w  w w. j a va  2s  . co m*/
    if (activity != null && weatherInfo != null) {
        View root = getView();

        TextView city = (TextView) root.findViewById(R.id.city);
        city.setText(weatherInfo.getCity());

        CurrentWeather currentWeather = weatherInfo.getCurrentWeather();

        RemoteImageView icon = (RemoteImageView) root.findViewById(R.id.icon);
        int resId = activity.getResources().getIdentifier(currentWeather.getIcon(), "drawable",
                activity.getPackageName());
        if (resId != 0) {
            ((ImageView) activity.findViewById(R.id.weather_small_logo)).setImageResource(resId);
            icon.setImageResource(resId);
        } else {
            ((ImageView) activity.findViewById(R.id.weather_small_logo)).setImageResource(R.drawable.unknown);
            icon.setImageResource(R.drawable.unknown);
        }

        TextView temp = (TextView) root.findViewById(R.id.temp);
        temp.setText(currentWeather.getTempF() + " \u00B0F | " + currentWeather.getTempC() + " \u00B0C");
        ((TextView) activity.findViewById(R.id.weather_small_text))
                .setText(currentWeather.getTempF() + "\u00B0");

        TextView condition = (TextView) root.findViewById(R.id.condition);
        String conditionText = currentWeather.getCondition();
        if (conditionText != null && !conditionText.equals("")) {
            condition.setText(conditionText);
        } else {
            condition.setText("N/A");
        }

        TextView windCondition = (TextView) root.findViewById(R.id.windCondition);
        windCondition.setText(currentWeather.getWindCondition());

        TextView humidity = (TextView) root.findViewById(R.id.humidity);
        humidity.setText(currentWeather.getHumidity());

        LinearLayout forcastConditions = (LinearLayout) root.findViewById(R.id.forcastConditions);
        forcastConditions.removeAllViews();

        LayoutInflater inflater = LayoutInflater.from(activity);
        LinearLayout.LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        params.weight = 1f;

        ArrayList<Condition> forcastArray = weatherInfo.getForcastConditions();
        for (int i = 0; i < forcastArray.size(); i++) {
            Condition forcastCondition = forcastArray.get(i);
            View forcastRoot = inflater.inflate(R.layout.fragment_weather_condition_item, null);

            TextView forcastDay = (TextView) forcastRoot.findViewById(R.id.day);
            forcastDay.setText(forcastCondition.getDay());

            RemoteImageView forcastIcon = (RemoteImageView) forcastRoot.findViewById(R.id.icon);
            int forcastResId = activity.getResources().getIdentifier(forcastCondition.getIcon(), "drawable",
                    activity.getPackageName());
            if (forcastResId != 0) {
                forcastIcon.setImageResource(forcastResId);
            } else {
                forcastIcon.setImageResource(R.drawable.unknown);
            }

            TextView forcastHigh = (TextView) forcastRoot.findViewById(R.id.high);
            forcastHigh.setText(forcastCondition.getHigh() + "\u00B0");

            TextView forcastLow = (TextView) forcastRoot.findViewById(R.id.low);
            forcastLow.setText(forcastCondition.getLow() + "\u00B0");

            forcastConditions.addView(forcastRoot, params);
        }
    }
}

From source file:au.com.cybersearch2.classyfy.TitleSearchResultsActivity.java

protected void showTitle(String title) {
    TextView tv1 = (TextView) findViewById(R.id.node_detail_title);
    tv1.setText(title);//from  ww  w  .  j a va 2  s .c om
    LinearLayout propertiesLayout = (LinearLayout) findViewById(R.id.node_properties);
    propertiesLayout.removeAllViews();
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.view.survey.SurveyInteractionView.java

@Override
public void doOnCreate(final Activity activity, Bundle savedInstanceState) {

    if (savedInstanceState != null) {
        surveySubmitted = savedInstanceState.getBoolean(KEY_SURVEY_SUBMITTED, false);
    }//from  w ww .  j a va  2  s.c  om

    if (interaction == null || surveySubmitted) {
        activity.finish();
        return;
    }

    activity.setContentView(R.layout.apptentive_survey);

    // Hide branding if needed.
    final View branding = activity.findViewById(R.id.apptentive_branding_view);
    if (branding != null) {
        if (Configuration.load(activity).isHideBranding(activity)) {
            branding.setVisibility(View.GONE);
        }
    }

    TextView title = (TextView) activity.findViewById(R.id.title);
    title.setFocusable(true);
    title.setFocusableInTouchMode(true);
    title.setText(interaction.getName());

    String descriptionText = interaction.getDescription();
    if (descriptionText != null) {
        TextView description = (TextView) activity.findViewById(R.id.description);
        description.setText(descriptionText);
        description.setVisibility(View.VISIBLE);
    }

    final Button send = (Button) activity.findViewById(R.id.send);
    send.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Util.hideSoftKeyboard(activity, view);
            surveySubmitted = true;
            if (interaction.isShowSuccessMessage() && interaction.getSuccessMessage() != null) {
                SurveyThankYouDialog dialog = new SurveyThankYouDialog(activity);
                dialog.setMessage(interaction.getSuccessMessage());
                dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialogInterface) {
                        activity.finish();
                    }
                });
                dialog.show();
            } else {
                activity.finish();
            }

            EngagementModule.engageInternal(activity, interaction, EVENT_SUBMIT, data.toString());
            ApptentiveDatabase.getInstance(activity).addPayload(new SurveyResponse(interaction, surveyState));
            Log.d("Survey Submitted.");
            callListener(true);

            cleanup();
        }
    });

    LinearLayout questions = (LinearLayout) activity.findViewById(R.id.questions);
    questions.removeAllViews();

    // Then render all the questions
    for (final Question question : interaction.getQuestions()) {
        if (question.getType() == Question.QUESTION_TYPE_SINGLELINE) {
            TextSurveyQuestionView textQuestionView = new TextSurveyQuestionView(activity, surveyState,
                    (SinglelineQuestion) question);
            textQuestionView.setOnSurveyQuestionAnsweredListener(new OnSurveyQuestionAnsweredListener() {
                public void onAnswered() {
                    sendMetricForQuestion(activity, question);
                    send.setEnabled(isSurveyValid());
                }
            });
            questions.addView(textQuestionView);
        } else if (question.getType() == Question.QUESTION_TYPE_MULTICHOICE) {
            MultichoiceSurveyQuestionView multichoiceQuestionView = new MultichoiceSurveyQuestionView(activity,
                    surveyState, (MultichoiceQuestion) question);
            multichoiceQuestionView.setOnSurveyQuestionAnsweredListener(new OnSurveyQuestionAnsweredListener() {
                public void onAnswered() {
                    sendMetricForQuestion(activity, question);
                    send.setEnabled(isSurveyValid());
                }
            });
            questions.addView(multichoiceQuestionView);
        } else if (question.getType() == Question.QUESTION_TYPE_MULTISELECT) {
            MultiselectSurveyQuestionView multiselectQuestionView = new MultiselectSurveyQuestionView(activity,
                    surveyState, (MultiselectQuestion) question);
            multiselectQuestionView.setOnSurveyQuestionAnsweredListener(new OnSurveyQuestionAnsweredListener() {
                public void onAnswered() {
                    sendMetricForQuestion(activity, question);
                    send.setEnabled(isSurveyValid());
                }
            });
            questions.addView(multiselectQuestionView);
        }
    }

    send.setEnabled(isSurveyValid());

    // Force the top of the survey to be shown first.
    title.requestFocus();
}

From source file:org.arasthel.almeribus.fragments.InfoParadaFragment.java

@Override
public void onStart() {
    ImageView favorito = (ImageView) getView().findViewById(R.id.favorito);
    favorito.setOnClickListener(new OnClickListener() {

        @Override/*from ww  w.  j a  v a 2  s.  c o m*/
        public void onClick(View arg0) {
            ImageView favorito = (ImageView) getView().findViewById(R.id.favorito);
            if (favorito.isSelected()) {
                DataStorage.DBHelper.removeFavorito(mNumParada);
                favorito.setImageResource(R.drawable.favorite_button);
            } else {
                DataStorage.DBHelper.addFavorito(mNumParada);
                favorito.setImageResource(R.drawable.ic_menu_favorite_on);
            }
            favorito.setSelected(!favorito.isSelected());
            Intent i = new Intent(ListaParadasFragment.UPDATE_FILTER);
            getActivity().sendBroadcast(i);
        }
    });
    boolean isFavorito = DataStorage.DBHelper.isFavorito(mNumParada);
    if (isFavorito) {
        favorito.setSelected(true);
        favorito.setImageResource(R.drawable.ic_menu_favorite_on);
    } else {
        favorito.setSelected(false);
        favorito.setImageResource(R.drawable.favorite_button);
    }

    ImageView verEnMapa = (ImageView) getView().findViewById(R.id.abrir_mapa);
    verEnMapa.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            double[] coord = DataStorage.paradas.get(mNumParada).getCoord();
            if (coord != null) {
                ((Principal) getActivity()).abrirMapaParadas(new LatLng(coord[1], coord[0]), true);
                ((MostrarInfoParada) getParentFragment()).dismiss();
            }
        }
    });

    LinearLayout listaTiempos = (LinearLayout) content.findViewById(R.id.tiemposEspera);
    listaTiempos.removeAllViews();
    if (mLineas.isEmpty()) {
        TextView tv = new TextView(getActivity());
        tv.setGravity(Gravity.CENTER);
        LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        lp.rightMargin = 10;
        lp.leftMargin = 10;
        lp.topMargin = 20;
        tv.setLayoutParams(lp);
        tv.setText(
                "No hay conexin de internet.\n\nPor favor, compruebe que dispone de conexin y vuelva a intentarlo.");
        listaTiempos.addView(tv);
    } else {
        calcularTiempos();
    }
    super.onStart();
}

From source file:free.yhc.netmbuddy.YTSearchActivity.java

private void adjustPageUserAction(int curPage) {
    int nrPages = getPagerAdapter().getNrPages();
    eAssert(curPage >= 1 && curPage <= nrPages);

    // Setup index buttons.
    LinearLayout ll = (LinearLayout) findViewById(R.id.indexgroup);
    ll.removeAllViews();
    int mini = curPage - (Policy.YTSEARCH_NR_PAGE_INDEX_BUTTONS / 2);
    if (mini < 1)
        mini = 1;/*ww w .ja  v  a  2s.  c  om*/

    int maxi = mini + Policy.YTSEARCH_NR_PAGE_INDEX_BUTTONS - 1;
    if (maxi > nrPages) {
        maxi = nrPages;
        mini = maxi - Policy.YTSEARCH_NR_PAGE_INDEX_BUTTONS + 1;
        if (mini < 1)
            mini = 1;
    }

    for (int i = mini; i <= maxi; i++) {
        int bi = i - mini;
        mPageBtnHolder[bi].setText("" + i);
        mPageBtnHolder[bi].setTag(i);
        mPageBtnHolder[bi].setBackgroundResource(R.drawable.btnbg_normal);
        ll.addView(mPageBtnHolder[bi], mPageBtnLPHolder);
    }
    mPageBtnHolder[curPage - mini].setBackgroundResource(R.drawable.btnbg_focused);
}