List of usage examples for android.widget LinearLayout removeAllViews
public void removeAllViews()
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
private void resetPredictionsView(LinearLayout predictions, boolean showInitLabel) { predictions.removeAllViews(); if (showInitLabel) { TextView tv1 = new TextView(this); tv1.setText("Predictions will appear Here"); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.weight = 1.f;//from w ww .ja v a 2s . co m params.gravity = Gravity.CENTER_VERTICAL; tv1.setLayoutParams(params); tv1.setTextSize(pixels5); predictions.addView(tv1); } if (saveButton != null) saveButton.setVisibility(View.INVISIBLE); if (loader != null) loader.setVisibility(View.INVISIBLE); }
From source file:cz.muni.fi.japanesedictionary.fragments.DisplayTranslation.java
/** * Displays map of characters to user. Called from CharacterLoader after loading has been done. *///from w w w. j a v a 2s.c om public void displayCharacters() { if (mCharacters == null || mCharacters.size() < 1 || getView() == null) { Log.w(LOG_TAG, "displayCharacters called - null"); return; } LinearLayout outerContainer = ((LinearLayout) getView().findViewById(R.id.translation_kanji_container)); if (outerContainer == null) { Log.w(LOG_TAG, "displayCharacters called - outerContainer null"); return; } Log.i(LOG_TAG, "displayCharacters called - display"); outerContainer.setVisibility(View.VISIBLE); String writeCharacters = mTranslation.getJapaneseKeb().get(0); LinearLayout container = (LinearLayout) getView().findViewById(R.id.translation_kanji_meanings_container); container.removeAllViews(); for (int i = 0; i < writeCharacters.length(); i++) { String character = String.valueOf(writeCharacters.charAt(i)); JapaneseCharacter japCharacter = mCharacters.get(character); if (japCharacter != null) { View translationKanji = mInflater.inflate(R.layout.kanji_line, container, false); TextView kanjiView = (TextView) translationKanji.findViewById(R.id.translation_kanji); kanjiView.setText(character); TextView meaningView = (TextView) translationKanji.findViewById(R.id.translation_kanji_meaning); if (mEnglish && japCharacter.getMeaningEnglish() != null) { int meaningSize = japCharacter.getMeaningEnglish().size(); if (meaningSize > 0) { int j = 0; StringBuilder strBuilder = new StringBuilder(); for (String str : japCharacter.getMeaningEnglish()) { strBuilder.append(str); j++; if (j < meaningSize) { strBuilder.append(", "); } } meaningView.setText(strBuilder); } } else if (mFrench && japCharacter.getMeaningFrench() != null) { int meaningSize = japCharacter.getMeaningFrench().size(); if (meaningSize > 0) { int j = 0; StringBuilder strBuilder = new StringBuilder(); for (String str : japCharacter.getMeaningFrench()) { strBuilder.append(str); j++; if (j < meaningSize) { strBuilder.append(", "); } } meaningView.setText(strBuilder); } } else if (mDutch && japCharacter.getMeaningDutch() != null) { int meaningSize = japCharacter.getMeaningDutch().size(); if (meaningSize > 0) { int j = 0; StringBuilder strBuilder = new StringBuilder(); for (String str : japCharacter.getMeaningDutch()) { strBuilder.append(str); j++; if (j < meaningSize) { strBuilder.append(", "); } } meaningView.setText(strBuilder); } } else if (mGerman && japCharacter.getMeaningGerman() != null) { int meaningSize = japCharacter.getMeaningGerman().size(); if (meaningSize > 0) { int j = 0; StringBuilder strBuilder = new StringBuilder(); for (String str : japCharacter.getMeaningGerman()) { strBuilder.append(str); j++; if (j < meaningSize) { strBuilder.append(", "); } } meaningView.setText(strBuilder); } } else if (mRussian && japCharacter.getMeaningRussian() != null) { int meaningSize = japCharacter.getMeaningRussian().size(); if (meaningSize > 0) { int j = 0; StringBuilder strBuilder = new StringBuilder(); for (String str : japCharacter.getMeaningRussian()) { strBuilder.append(str); j++; if (j < meaningSize) { strBuilder.append(", "); } } meaningView.setText(strBuilder); } } else { meaningView.setText(getString(R.string.translation_kanji_no_meaning)); } translationKanji.findViewById(R.id.kanji_line_id).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TextView textView = (TextView) v.findViewById(R.id.translation_kanji); mCallbackTranslation.showKanjiDetail(mCharacters.get(textView.getText().toString())); } }); container.addView(translationKanji); } } }
From source file:org.linphone.ContactEditorFragment.java
private LinearLayout initNumbersFields(final Contact contact) { LinearLayout controls = (LinearLayout) view.findViewById(R.id.controls_numbers); controls.removeAllViews(); if (contact != null) { for (String numberOrAddress : contact.getNumbersOrAddresses()) { boolean isSip = LinphoneUtils.isStrictSipAddress(numberOrAddress) || !LinphoneUtils.isNumberAddress(numberOrAddress); if (!isSip) { View view = displayNumberOrAddress(controls, numberOrAddress); if (view != null) controls.addView(view); }//from ww w . j ava2 s .c om } } if (newSipOrNumberToAdd != null) { boolean isSip = LinphoneUtils.isStrictSipAddress(newSipOrNumberToAdd) || !LinphoneUtils.isNumberAddress(newSipOrNumberToAdd); if (!isSip) { View view = displayNumberOrAddress(controls, newSipOrNumberToAdd); if (view != null) controls.addView(view); } } if (controls.getChildCount() == 0) { addEmptyRowToAllowNewNumberOrAddress(controls, false); } return controls; }
From source file:org.linphone.ContactEditorFragment.java
private LinearLayout initSipAddressFields(final Contact contact) { LinearLayout controls = (LinearLayout) view.findViewById(R.id.controls_sip_address); controls.removeAllViews(); if (contact != null) { for (String numberOrAddress : contact.getNumbersOrAddresses()) { boolean isSip = LinphoneUtils.isStrictSipAddress(numberOrAddress) || !LinphoneUtils.isNumberAddress(numberOrAddress); if (isSip) { View view = displayNumberOrAddress(controls, numberOrAddress); if (view != null) controls.addView(view); }// www . j a va 2 s. c o m } } if (newSipOrNumberToAdd != null) { boolean isSip = LinphoneUtils.isStrictSipAddress(newSipOrNumberToAdd) || !LinphoneUtils.isNumberAddress(newSipOrNumberToAdd); if (isSip) { View view = displayNumberOrAddress(controls, newSipOrNumberToAdd); if (view != null) controls.addView(view); } } if (controls.getChildCount() == 0) { addEmptyRowToAllowNewNumberOrAddress(controls, true); } return controls; }
From source file:com.example.volunteerhandbook.MainActivity.java
void loopNewBox(LinearLayout iBox) { if (lastone <= 1) { show_what_I_thought();//from w w w.j a v a 2 s .c om return; } if (iTh > 3 * thoughts.length + 2) { lastone--; return; } float bH = (int) (1.2 * iBox.getHeight()); iBox.removeAllViews(); for (int i = 0; i < thoughts.length / 4; i++) { iBox.addView(toMove[iTh++ % thoughts.length]); } //toMove.setTranslationY(600); //container.addView(textBox); iBox.setX(20); iBox.setY(2 * bH); //hBox += iBox.getHeight(); float startY = iBox.getY(); endY = (-1) * bH; int duration = 20000; ValueAnimator bounceAnim = ObjectAnimator.ofFloat(iBox, "y", startY, endY); bounceAnim.setDuration(duration); bounceAnim.setInterpolator(new LinearInterpolator()); final LinearLayout fBox = iBox; bounceAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { loopNewBox(fBox); } }); bounceAnim.start(); }
From source file:com.luseen.spacenavigation.SpaceNavigationView.java
/** * Adding given space items to content// w w w. ja va 2 s.c o m * * @param leftContent to left content * @param rightContent and right content */ private void addSpaceItems(LinearLayout leftContent, LinearLayout rightContent) { /** * Removing all views for not being duplicated */ if (leftContent.getChildCount() > 0 || rightContent.getChildCount() > 0) { leftContent.removeAllViews(); rightContent.removeAllViews(); } /** * Clear spaceItemList and badgeList for not being duplicated */ spaceItemList.clear(); badgeList.clear(); /** * Getting LayoutInflater to inflate space item view from XML */ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < spaceItems.size(); i++) { final int index = i; int targetWidth; if (spaceItems.size() > 2) targetWidth = contentWidth / 2; else targetWidth = contentWidth; RelativeLayout.LayoutParams textAndIconContainerParams = new RelativeLayout.LayoutParams(targetWidth, mainContentHeight); RelativeLayout textAndIconContainer = (RelativeLayout) inflater.inflate(R.layout.space_item_view, this, false); textAndIconContainer.setLayoutParams(textAndIconContainerParams); ImageView spaceItemIcon = (ImageView) textAndIconContainer.findViewById(R.id.space_icon); TextView spaceItemText = (TextView) textAndIconContainer.findViewById(R.id.space_text); RelativeLayout badgeContainer = (RelativeLayout) textAndIconContainer .findViewById(R.id.badge_container); spaceItemIcon.setImageResource(spaceItems.get(i).getItemIcon()); spaceItemText.setText(spaceItems.get(i).getItemName()); spaceItemText.setTextSize(TypedValue.COMPLEX_UNIT_PX, spaceItemTextSize); /** * Set custom font to space item textView */ if (isCustomFont) spaceItemText.setTypeface(customFont); /** * Hide item icon and show only text */ if (textOnly) Utils.changeViewVisibilityGone(spaceItemIcon); /** * Hide item text and change icon size */ ViewGroup.LayoutParams iconParams = spaceItemIcon.getLayoutParams(); if (iconOnly) { iconParams.height = spaceItemIconOnlySize; iconParams.width = spaceItemIconOnlySize; spaceItemIcon.setLayoutParams(iconParams); Utils.changeViewVisibilityGone(spaceItemText); } else { iconParams.height = spaceItemIconSize; iconParams.width = spaceItemIconSize; spaceItemIcon.setLayoutParams(iconParams); } /** * Adding space items to item list for future */ spaceItemList.add(textAndIconContainer); /** * Adding badge items to badge list for future */ badgeList.add(badgeContainer); /** * Adding sub views to left and right sides */ if (spaceItems.size() == 2 && leftContent.getChildCount() == 1) { rightContent.addView(textAndIconContainer, textAndIconContainerParams); } else if (spaceItems.size() > 2 && leftContent.getChildCount() == 2) { rightContent.addView(textAndIconContainer, textAndIconContainerParams); } else { leftContent.addView(textAndIconContainer, textAndIconContainerParams); } /** * Changing current selected item tint */ if (i == currentSelectedItem) { spaceItemText.setTextColor(activeSpaceItemColor); Utils.changeImageViewTint(spaceItemIcon, activeSpaceItemColor); } else { spaceItemText.setTextColor(inActiveSpaceItemColor); Utils.changeImageViewTint(spaceItemIcon, inActiveSpaceItemColor); } textAndIconContainer.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { updateSpaceItems(index); } }); } /** * Restore available badges from saveInstance */ restoreBadges(); }
From source file:mp.teardrop.LibraryPagerAdapter.java
void updateLimiterViews() { LinearLayout limiterViews = (LinearLayout) mContainingLayouts[mTabOrder[mCurrentPage]] .findViewById(R.id.new_limiter_layout); if (limiterViews == null) { return;// w w w. j a va2 s . c om } limiterViews.removeAllViews(); Limiter limiterData = getCurrentLimiter(); if (mTabOrder[mCurrentPage] == MediaUtils.TYPE_FILE || mTabOrder[mCurrentPage] == MediaUtils.TYPE_DROPBOX) { //always create an element representing the root directory TextView textView1 = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null); textView1.setText(R.string.root_directory); textView1.setTag(LibraryActivity.TAG_DELIMITER_ROOT); //used to handle click event properly textView1.setOnClickListener(mActivity); limiterViews.addView(textView1); mLimiterScroller.setVisibility(View.VISIBLE); } else if (mTabOrder[mCurrentPage] == MediaUtils.TYPE_UNIFIED) { // always create a link to the root of the library TextView textView1 = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null); textView1.setText(R.string.library); textView1.setTag(LibraryActivity.TAG_DELIMITER_ROOT); //used to handle click event properly textView1.setOnClickListener(mActivity); limiterViews.addView(textView1); //create a link to all albums, artists or songs if applicable if (limiterData != null && (limiterData.type != UnifiedAdapter.ITEM_TYPE_MORE_ALBUMS && limiterData.type != UnifiedAdapter.ITEM_TYPE_MORE_ARTISTS && limiterData.type != UnifiedAdapter.ITEM_TYPE_MORE_SONGS && limiterData.type != UnifiedAdapter.ITEM_TYPE_MORE_PLAYLISTS)) { textView1 = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null); textView1.setText(R.string.limiter_separator); textView1.setTextColor(0xa3ffffff); limiterViews.addView(textView1); textView1 = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null); switch (limiterData.type) { case UnifiedAdapter.ITEM_TYPE_ARTIST: textView1.setText(R.string.artists); textView1.setTag(LibraryActivity.TAG_ARTISTS_ROOT); break; case UnifiedAdapter.ITEM_TYPE_ALBUM: textView1.setText(R.string.albums); textView1.setTag(LibraryActivity.TAG_ALBUMS_ROOT); break; case UnifiedAdapter.ITEM_TYPE_PLAYLIST: textView1.setText(R.string.playlists); textView1.setTag(LibraryActivity.TAG_PLAYLISTS_ROOT); break; } textView1.setOnClickListener(mActivity); limiterViews.addView(textView1); } } if (limiterData != null) { String[] limiter = limiterData.names; for (int i = 0; i != limiter.length; ++i) { TextView textView = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null); textView.setText(R.string.limiter_separator); textView.setTextColor(0xa3ffffff); limiterViews.addView(textView); textView = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null); textView.setText(limiter[i]); textView.setTag(i); textView.setOnClickListener(mActivity); limiterViews.addView(textView); } } }
From source file:net.willwebberley.gowertides.ui.DayFragment.java
private void setSurfInfo() { double x = dayView.getApplicationContext().getResources().getDisplayMetrics().density; LinearLayout surf = (LinearLayout) layoutView.findViewById(R.id.surf); // Get the linear layout to add the surf details to // Set some basic layout params (last arg is weight - set to 0.2) LinearLayout.LayoutParams param = new LinearLayout.LayoutParams((int) (x * 100), LinearLayout.LayoutParams.MATCH_PARENT); // Calculate the pixel density (in dpi)... // ... and use this to set the horizontal margins of the views to be added to the LinearLayout (i.e. 5dpi left and right) param.setMargins((int) (5 * x), 0, (int) (5 * x), 0); // Finally remove all views in there already, before repopulating with the layoutparams specified above. surf.removeAllViews(); ArrayList<Surf> reports = day.getSurfReports(); for (int i = 0; i < reports.size(); i++) { SurfFragment si = new SurfFragment(dayView.getApplicationContext(), reports.get(i)); surf.addView(si.getView(), param); }/* w w w.ja v a2 s .com*/ }
From source file:com.sft.blackcatapp.EnrollSchoolActivity.java
private void showOpenCityPopupWindow(View parent) { if (openCityPopupWindow == null) { LinearLayout popWindowLayout = (LinearLayout) View.inflate(mContext, R.layout.pop_window, null); popWindowLayout.removeAllViews(); // LinearLayout popWindowLayout = new LinearLayout(mContext); popWindowLayout.setOrientation(LinearLayout.VERTICAL); ListView OpenCityListView = new ListView(mContext); OpenCityListView.setDividerHeight(0); OpenCityListView.setCacheColorHint(android.R.color.transparent); OpenCityListView.setOnItemClickListener(new OnItemClickListener() { @Override/*from ww w . j a va 2 s .c o m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { OpenCityVO selectCity = openCityList.get(position); System.out.println(selectCity.getName()); cityname = selectCity.getName(); licensetype = ""; schoolname = ""; ordertype = ""; index = 1; obtainNearBySchool(); openCityPopupWindow.dismiss(); openCityPopupWindow = null; } }); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); popWindowLayout.addView(OpenCityListView, param); OpenCityAdapter openCityAdapter = new OpenCityAdapter(mContext, openCityList); OpenCityListView.setAdapter(openCityAdapter); openCityPopupWindow = new PopupWindow(popWindowLayout, 130, LayoutParams.WRAP_CONTENT); } openCityPopupWindow.setFocusable(true); openCityPopupWindow.setOutsideTouchable(true); // Back??? openCityPopupWindow.setBackgroundDrawable(new BitmapDrawable()); openCityPopupWindow.showAsDropDown(parent); }
From source file:net.willwebberley.gowertides.ui.DayFragment.java
private void setTideTableInfo() { LinearLayout tides = (LinearLayout) layoutView.findViewById(R.id.tides); // Get the linear layout to add the surf details to LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT); // Calculate the pixel density (in dpi)... double x = dayView.getApplicationContext().getResources().getDisplayMetrics().density; // ... and use this to set the horizontal margins of the views to be added to the LinearLayout (i.e. 5dpi left and right) param.setMargins((int) (5 * x), 0, (int) (5 * x), 0); // Finally remove all views in there already, before repopulating with the layoutparams specified above. tides.removeAllViews(); ArrayList<Tide> forecasts = day.getTides(); for (int i = 0; i < forecasts.size(); i++) { TideFragment ti = new TideFragment(dayView.getApplicationContext(), forecasts.get(i), day); tides.addView(ti.getView(), param); }// ww w. java2 s . c o m }