List of usage examples for android.widget LinearLayout removeAllViews
public void removeAllViews()
From source file:org.mklab.mikity.android.FileSelectionFragment.java
/** * ???????//from w w w . j a v a2 s .co m * * @param mainView */ private void createSourceComponent(View mainView) { final List<GroupModel> rootGroups = this.canvasFragment.root.getScene(0).getGroups(); final Set<String> sourceIds = getAllSourceIds(rootGroups); final LinearLayout sources = (LinearLayout) mainView.findViewById(R.id.layout_sources); sources.removeAllViews(); this.sourceSelectButtons.clear(); this.sourceReloadButtons.clear(); this.sourceFileNameViews.clear(); for (final String sourceId : sourceIds) { final LinearLayout source = (LinearLayout) FileSelectionFragment.this.mainActivity.getLayoutInflater() .inflate(R.layout.source, null); sources.addView(source); final Button selectButton = (Button) source.findViewById(R.id.sourceSelectButton); selectButton.setText(getString(R.string.source) + "(" + sourceId + ")"); //$NON-NLS-1$ //$NON-NLS-2$ this.sourceSelectButtons.add(selectButton); selectButton.setOnClickListener(new View.OnClickListener() { /** * {@inheritDoc} */ public void onClick(View view) { FileSelectionFragment.this.mainActivity.sendFileChooseIntentForLoadingSource(sourceId); } }); final TextView fileNameView = (TextView) source.findViewById(R.id.sourceFileNameView); if (this.sourceFileNames.containsKey(sourceId)) { fileNameView.setText(this.sourceFileNames.get(sourceId)); } this.sourceFileNameViews.put(sourceId, fileNameView); final Button reloadButton = (Button) source.findViewById(R.id.sourceReloadButton); this.sourceReloadButtons.add(reloadButton); reloadButton.setOnClickListener(new View.OnClickListener() { /** * {@inheritDoc} */ public void onClick(View view) { if (FileSelectionFragment.this.canvasFragment.sourceData.containsKey(sourceId)) { FileSelectionFragment.this.canvasFragment.addSource(sourceId); } } }); } }
From source file:org.fdroid.fdroid.privileged.views.AppSecurityPermissions.java
/** * Utility method that displays permissions from a map containing group name and * list of permission descriptions./*from w w w.ja v a 2s.com*/ */ private void displayPermissions(List<MyPermissionGroupInfo> groups, LinearLayout permListView, int which) { permListView.removeAllViews(); int spacing = (int) (8 * context.getResources().getDisplayMetrics().density); for (MyPermissionGroupInfo grp : groups) { final List<MyPermissionInfo> perms = getPermissionList(grp, which); for (int j = 0; j < perms.size(); j++) { MyPermissionInfo perm = perms.get(j); View view = getPermissionItemView(grp, perm, j == 0, which != WHICH_NEW ? newPermPrefix : null); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); if (j == 0) { lp.topMargin = spacing; } if (j == grp.allPermissions.size() - 1) { lp.bottomMargin = spacing; } if (permListView.getChildCount() == 0) { lp.topMargin *= 2; } permListView.addView(view, lp); } } }
From source file:org.rm3l.ddwrt.fragments.status.StatusWirelessFragment.java
/** * Called when a previously created loader has finished its load. Note * that normally an application is <em>not</em> allowed to commit fragment * transactions while in this call, since it can happen after an * activity's state is saved. See {@link android.support.v4.app.FragmentManager#beginTransaction() * FragmentManager.openTransaction()} for further discussion on this. * <p/>/*from ww w . j a v a 2s .co m*/ * <p>This function is guaranteed to be called prior to the release of * the last data that was supplied for this Loader. At this point * you should remove all use of the old data (since it will be released * soon), but should not do your own release of the data since its Loader * owns it and will take care of that. The Loader will take care of * management of its data so you don't have to. In particular: * <p/> * <ul> * <li> <p>The Loader will monitor for changes to the data, and report * them to you through new calls here. You should not monitor the * data yourself. For example, if the data is a {@link android.database.Cursor} * and you place it in a {@link android.widget.CursorAdapter}, use * the {@link android.widget.CursorAdapter#CursorAdapter(android.content.Context, * android.database.Cursor, int)} constructor <em>without</em> passing * in either {@link android.widget.CursorAdapter#FLAG_AUTO_REQUERY} * or {@link android.widget.CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER} * (that is, use 0 for the flags argument). This prevents the CursorAdapter * from doing its own observing of the Cursor, which is not needed since * when a change happens you will get a new Cursor throw another call * here. * <li> The Loader will release the data once it knows the application * is no longer using it. For example, if the data is * a {@link android.database.Cursor} from a {@link android.content.CursorLoader}, * you should not call close() on it yourself. If the Cursor is being placed in a * {@link android.widget.CursorAdapter}, you should use the * {@link android.widget.CursorAdapter#swapCursor(android.database.Cursor)} * method so that the old Cursor is not closed. * </ul> * * @param loader The Loader that has finished. * @param tiles The data generated by the Loader. */ @Override public void onLoadFinished(final Loader<Collection<DDWRTTile>> loader, @Nullable final Collection<DDWRTTile> tiles) { Log.d(LOG_TAG, "Done loading background task for " + StatusWirelessFragment.class.getCanonicalName()); this.mIfaceTiles = tiles; if (viewGroup == null || tiles == null || tiles.isEmpty()) { return; } final SherlockFragmentActivity sherlockActivity = getSherlockActivity(); final int themeBackgroundColor = getThemeBackgroundColor(sherlockActivity, router.getUuid()); final boolean isThemeLight = isThemeLight(sherlockActivity, themeBackgroundColor); final LinearLayout dynamicTilessViewGroup = (LinearLayout) viewGroup .findViewById(R.id.tiles_container_scrollview_layout_dynamic_items); //Remove everything first dynamicTilessViewGroup.removeAllViews(); for (@NotNull final DDWRTTile tile : tiles) { @Nullable final ViewGroup tileViewGroupLayout = tile.getViewGroupLayout(); if (tileViewGroupLayout == null) { continue; } if (isThemeLight) { final View titleView = tileViewGroupLayout.findViewById(tile.getTileTitleViewId()); if (titleView instanceof TextView) { ((TextView) titleView).setTextColor(getResources().getColor(android.R.color.holo_blue_dark)); } } tileViewGroupLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent)); //Init loaders for these tiles getSherlockActivity().getSupportLoaderManager() .initLoader(Long.valueOf(Utils.getNextLoaderId()).intValue(), null, tile); //Add row for this iface final CardView cardView = new CardView(sherlockActivity); cardView.setCardBackgroundColor(themeBackgroundColor); cardView.setOnClickListener(tile); tileViewGroupLayout.setOnClickListener(tile); cardView.addView(tileViewGroupLayout); //Remove view prior to adding it again to parent dynamicTilessViewGroup.addView(cardView); } //Make it visible now dynamicTilessViewGroup.setVisibility(View.VISIBLE); }
From source file:com.ess.tudarmstadt.de.sleepsense.mgraph.GraphPlotFragment.java
private void createGraph(String graphTitle, GraphViewSeries series, final int Rid, boolean isBarChart) { GraphView graphView = null;//from w w w . j ava 2 s .c o m if (isBarChart) { graphView = new BarGraphView(getActivity().getApplicationContext(), graphTitle); // graphView.setVerticalLabels(new String[] { "high", "mid", "low" // }); // graphView.setManualYAxisBounds(11.0d, 9.0d); } else graphView = new LineGraphView(getActivity().getApplicationContext(), graphTitle); graphView.setCustomLabelFormatter(new CustomLabelFormatter() { @Override public String formatLabel(double axis_value, boolean isValueX) { if (isValueX) { // X-Axis // decompose x_axis from adding up before double value = axis_value; if (axis_value >= 200) { value = axis_value - 200; } else if (axis_value > 0) value = axis_value - 100; // make sure not have smth like 4:60 or 11:83 time frame! double whole = value; double fractionalPart = value % 1; double integralPart = value - fractionalPart; if (fractionalPart >= 0.60) { whole = integralPart + 1.0d + (fractionalPart - 0.60); } // convert (double) hour.mm to hour:mm return new DecimalFormat("00.00").format(whole).replaceAll("\\,", ":"); } else { // Y-Axis return new DecimalFormat("#0.00").format(axis_value); } } }); // add data graphView.addSeries(series); graphView.setScrollable(false); // optional - activate scaling / zooming // graphView.setScalable(true); // optional - legend // graphView.setShowLegend(true); if (Rid == R.id.sleep_pattern) { graphView.setManualYAxisBounds(1.0d, 0.0d); } graphView.getGraphViewStyle().setNumVerticalLabels(4); graphView.getGraphViewStyle().setNumHorizontalLabels(0); // AUTO graphView.getGraphViewStyle().setTextSize(17f); graphView.getGraphViewStyle().setVerticalLabelsAlign(Align.CENTER); graphView.getGraphViewStyle().setVerticalLabelsWidth(80); LinearLayout layout = (LinearLayout) rootView.findViewById(Rid); layout.removeAllViews(); layout.addView(graphView); rootView.postInvalidate(); }
From source file:app.jorge.mobile.com.transportalert.ScrollingActivity.java
@Override public void onRefresh() { mSwipeRefreshLayout.setRefreshing(false); LinearLayout item = (LinearLayout) findViewById(R.id.rv); if (item.getChildCount() > 0) { item.removeAllViews(); }//from ww w. ja v a2 s . c o m addAllCards(item); // asynchronous Retrofit retrofit = new Retrofit.Builder().baseUrl(getString(R.string.url_tfl_api)) .addConverterFactory(GsonConverterFactory.create()).build(); TaskService taskService = retrofit.create(TaskService.class); Call<List<StatusLine>> call = taskService.login(getString(R.string.app_id), getString(R.string.app_key)); call.enqueue(this); }
From source file:de.enlightened.peris.MessageActivity.java
private void renderMessage(final Message message) { final Context context = this.getApplicationContext(); final SharedPreferences appPreferences = context.getSharedPreferences("prefs", 0); final boolean useShading = appPreferences.getBoolean("use_shading", false); final boolean useOpenSans = appPreferences.getBoolean("use_opensans", false); final int fontSize = appPreferences.getInt("font_size", DEFAULT_FONT_SIZE); final boolean currentAvatarSetting = appPreferences.getBoolean("show_images", true); final Typeface opensans = Typeface.createFromAsset(context.getAssets(), "fonts/opensans.ttf"); final View view = this.findViewById(R.id.message_layout); final TextView poAuthor = (TextView) view.findViewById(R.id.message_author); final TextView poTimestamp = (TextView) view.findViewById(R.id.message_timestamp); final TextView tvOnline = (TextView) view.findViewById(R.id.message_online_status); final LinearLayout llBorderBackground = (LinearLayout) view.findViewById(R.id.ll_border_background); final LinearLayout llColorBackground = (LinearLayout) view.findViewById(R.id.ll_color_background); String textColor = context.getString(R.string.default_text_color); if (this.application.getSession().getServer().serverTextColor.contains("#")) { textColor = this.application.getSession().getServer().serverTextColor; }//from w w w . ja va 2 s . c om String boxColor = context.getString(R.string.default_element_background); if (this.application.getSession().getServer().serverBoxColor != null) { boxColor = this.application.getSession().getServer().serverBoxColor; } if (boxColor.contains("#")) { llColorBackground.setBackgroundColor(Color.parseColor(boxColor)); } else { llColorBackground.setBackgroundColor(Color.TRANSPARENT); } //TODO: remove border? String boxBorder = context.getString(R.string.default_element_border); if (this.application.getSession().getServer().serverBoxBorder != null) { boxBorder = this.application.getSession().getServer().serverBoxBorder; } if (boxBorder.contentEquals("1")) { llBorderBackground.setBackgroundResource(R.drawable.element_border); } else { llBorderBackground.setBackgroundColor(Color.TRANSPARENT); } if (useOpenSans) { poAuthor.setTypeface(opensans); poTimestamp.setTypeface(opensans); tvOnline.setTypeface(opensans); } if (useShading) { poAuthor.setShadowLayer(2, 0, 0, Color.parseColor("#66000000")); tvOnline.setShadowLayer(2, 0, 0, Color.parseColor("#66000000")); } final LinearLayout llPostBodyHolder = (LinearLayout) view.findViewById(R.id.message_body_holder); llPostBodyHolder.removeAllViews(); final ImageView poAvatar = (ImageView) view.findViewById(R.id.message_avatar); if (boxColor != null && boxColor.contains("#") && boxColor.length() == 7) { final ImageView postAvatarFrame = (ImageView) view.findViewById(R.id.message_avatar_frame); postAvatarFrame.setColorFilter(Color.parseColor(boxColor)); } else { final ImageView postAvatarFrame = (ImageView) view.findViewById(R.id.message_avatar_frame); postAvatarFrame.setVisibility(View.GONE); } if (message.isAuthorOnline()) { tvOnline.setText("ONLINE"); tvOnline.setVisibility(View.VISIBLE); } else { tvOnline.setVisibility(View.GONE); } poAuthor.setText(message.getAuthor()); poTimestamp.setText(DateTimeUtils.getTimeAgo(message.getTimestamp())); final String postContent = message.getBody(); // TODO: add attachments BBCodeParser.parseCode(context, llPostBodyHolder, postContent, opensans, useOpenSans, useShading, new ArrayList<PostAttachment>(), fontSize, true, textColor, this.application); poAuthor.setTextColor(Color.parseColor(textColor)); poTimestamp.setTextColor(Color.parseColor(textColor)); if (currentAvatarSetting) { if (Net.isUrl(message.getAuthorAvatar())) { final String imageUrl = message.getAuthorAvatar(); ImageLoader.getInstance().displayImage(imageUrl, poAvatar); } else { poAvatar.setImageResource(R.drawable.no_avatar); } } else { poAvatar.setVisibility(View.GONE); } }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.fragments.GraphPlotFragment.java
private void createGraph(String graphTitle, GraphViewSeries series, int Rid, boolean isBarChart) { GraphView graphView = null;/* ww w . j a v a2 s .c o m*/ if (isBarChart) { graphView = new BarGraphView(getActivity().getApplicationContext(), graphTitle); // graphView.setVerticalLabels(new String[] { "high", "mid", "low" // }); // graphView.setManualYAxisBounds(11.0d, 9.0d); } else graphView = new LineGraphView(getActivity().getApplicationContext(), graphTitle); graphView.setCustomLabelFormatter(new CustomLabelFormatter() { @Override public String formatLabel(double value, boolean isValueX) { // make sure not have smth like 4:60 or 11:83 time frame! double whole = value; double fractionalPart = value % 1; double integralPart = value - fractionalPart; if (fractionalPart > 0.59) { whole = integralPart + 1.0d + (fractionalPart - 0.60); } if (isValueX) { // convert (double) hour.mm to hour:mm return new DecimalFormat("00.00").format(whole).replaceAll("\\,", ":"); } else { if (value > 1000) { return "high"; } return new DecimalFormat("#0.00").format(value); } } }); // add data graphView.addSeries(series); graphView.setScrollable(false); // optional - activate scaling / zooming // graphView.setScalable(true); // optional - legend // graphView.setShowLegend(true); graphView.getGraphViewStyle().setNumVerticalLabels(3); graphView.getGraphViewStyle().setNumHorizontalLabels(3); graphView.getGraphViewStyle().setVerticalLabelsWidth(80); LinearLayout layout = (LinearLayout) rootView.findViewById(Rid); layout.removeAllViews(); layout.addView(graphView); rootView.postInvalidate(); }
From source file:org.ale.scanner.zotero.EditItemActivity.java
private void fillForm() { // Clear any previous data from the form LinearLayout container = ((LinearLayout) findViewById(R.id.editContainer)); container.removeAllViews(); // Get the JSON we'll be working from. JSONObject info = mWorkingItem.getSelectedInfo(); final String[] fields; // XXX: temporary hack. In-order list of fields if (ItemType.book.equals(info.optString(ItemField.itemType))) { fields = new String[] { "title", "creators", "abstractNote", "series", "seriesNumber", "volume", "numberOfVolumes", "edition", "place", "publisher", "date", "numPages", "language", "ISBN", "shortTitle", "url", "accessDate", "archive", "archiveLocation", "libraryCatalog", "callNumber", "rights", "extra", "notes", "tags" }; } else { // XXX: Assumes journalArticle fields = new String[] { "title", "creators", "abstractNote", "publicationTitle", "volume", "issue", "pages", "date", "series", "seriesTitle", "seriesText", "journalAbbreviation", "language", "DOI", "ISSN", "shortTitle", "url", "accessDate", "archive", "archiveLocation", "libraryCatalog", "callNumber", "rights", "extra", "tags", "notes" }; }// www . j av a 2 s . c o m LinearLayout row; LinearLayout crow; int row_ctr = 0; for (String field : fields) { if (field.equals(ItemField.itemType)) continue; if (field.equals(ItemField.creators)) { row = mCreatorList = (LinearLayout) mInflater.inflate(R.layout.edit_creators, container, false); JSONArray creators = info.optJSONArray(field); if (creators == null || creators.length() == 0) { addCreator(); // Empty creator row for new creators } else { for (int c = 0; c < creators.length(); c++) { JSONObject creator = creators.optJSONObject(c); if (creator == null) continue; crow = addCreator(); Spinner sp = (Spinner) crow.findViewById(R.id.creator_type); EditText et = (EditText) crow.findViewById(R.id.creator); String curtype = creator.optString(CreatorType.type); int selection = CreatorType.Book.indexOf(curtype); sp.setSelection(selection >= 0 ? selection : 0); String name = creator.optString(ItemField.Creator.name); if (TextUtils.isEmpty(name)) { String[] firstlast = { creator.optString(ItemField.Creator.firstName), creator.optString(ItemField.Creator.lastName) }; name = TextUtils.join(" ", firstlast); } et.setText(name); } } } else if (field.equals(ItemField.notes)) { row = mNoteList = (LinearLayout) mInflater.inflate(R.layout.edit_notes, container, false); JSONArray notes = info.optJSONArray(field); if (notes == null || notes.length() == 0) { addNote(); // Empty note row for new notes } else { for (int c = 0; c < notes.length(); c++) { JSONObject note = notes.optJSONObject(c); if (note == null) continue; crow = addNote(); EditText et = (EditText) crow.findViewById(R.id.content); et.setText(note.optString(ItemField.Note.note)); } } } else if (field.equals(ItemField.tags)) { row = mTagList = (LinearLayout) mInflater.inflate(R.layout.edit_tags, container, false); JSONArray tags = info.optJSONArray(field); if (tags == null || tags.length() == 0) { addTag(); // Empty tag row for new tags } else { for (int c = 0; c < tags.length(); c++) { JSONObject tag = tags.optJSONObject(c); if (tag == null) continue; crow = addTag(); EditText et = (EditText) crow.findViewById(R.id.content); et.setText(tag.optString(ItemField.Tag.tag)); } } } else { row = (LinearLayout) mInflater.inflate(R.layout.edit_field, container, false); TextView tv_lbl = (TextView) row.findViewById(R.id.label); EditText et = (EditText) row.findViewById(R.id.content); tv_lbl.setText(ItemField.Localized.get(field)); tv_lbl.setTag(field); et.setText(info.optString(field)); } container.addView(row); setRowColor(row, row_ctr); row_ctr++; } }
From source file:com.gh4a.fragment.UserFragment.java
public void fillOrganizations(List<User> organizations) { ViewGroup llOrgs = (ViewGroup) mContentView.findViewById(R.id.ll_orgs); LinearLayout llOrg = (LinearLayout) mContentView.findViewById(R.id.ll_org); int count = organizations != null ? organizations.size() : 0; LayoutInflater inflater = getLayoutInflater(null); llOrg.removeAllViews(); llOrgs.setVisibility(count > 0 ? View.VISIBLE : View.GONE); for (int i = 0; i < count; i++) { User org = organizations.get(i); View rowView = inflater.inflate(R.layout.selectable_label_with_avatar, llOrg, false); rowView.setOnClickListener(this); rowView.setTag(org);/*from w ww . j a v a 2 s . co m*/ ImageView avatar = (ImageView) rowView.findViewById(R.id.iv_gravatar); AvatarHandler.assignAvatar(avatar, org); TextView nameView = (TextView) rowView.findViewById(R.id.tv_title); nameView.setText(org.getLogin()); llOrg.addView(rowView); } }
From source file:es.usc.citius.servando.calendula.activities.CalendarActivity.java
public void hideBottomSheet() { LinearLayout list = (LinearLayout) findViewById(R.id.pickup_list); list.removeAllViews(); appBarLayout.setExpanded(true, true); bottomSheet.setVisibility(View.INVISIBLE); }