List of usage examples for android.widget LinearLayout removeAllViews
public void removeAllViews()
From source file:org.gots.seed.view.SeedWidgetTile.java
@SuppressWarnings("deprecation") private void setupView() { if (mSeed == null) return;//from w ww. jav a 2 s . co m // int familyImageRessource = 0; // if (mSeed.getFamily() != null) // familyImageRessource = getResources().getIdentifier( // "org.gots:drawable/family_" + mSeed.getFamily().toLowerCase(), null, null); // // if (familyImageRessource != 0) // setBackgroundResource(familyImageRessource); // else { // int sdk = android.os.Build.VERSION.SDK_INT; // if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { // setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.family_unknown)); // } else { // setBackground(mContext.getResources().getDrawable(R.drawable.family_unknown)); // } // } SeedWidget seedWidget = (SeedWidget) findViewById(R.id.idSeedWidget2); seedWidget.setSeed(mSeed); TextView seedSpecie = (TextView) findViewById(R.id.IdSeedSpecie); seedSpecie.setText(SeedUtil.translateSpecie(mContext, mSeed)); if (GotsPreferences.DEBUG) seedSpecie.setText("(" + mSeed.getSeedId() + ")" + SeedUtil.translateSpecie(mContext, mSeed)); TextView seedVariety = (TextView) findViewById(R.id.IdSeedVariety); seedVariety.setText(mSeed.getVariety()); state = (ImageView) findViewById(R.id.imageStateValidation); if ("approved".equals(mSeed.getState())) state.setVisibility(View.VISIBLE); else state.setVisibility(View.GONE); // PlanningWidget planningSow = (PlanningWidget) fidindViewById(R.id.IdSeedSowingPlanning); // planningSow.setAdapter(new PlanningSowAdapter(mSeed)); // // // PlanningWidget planningHarvest = (PlanningWidget) findViewById(R.id.IdSeedHarvestPlanning); // planningHarvest.setAdapter(new PlanningHarvestAdapter(mSeed)); LinearLayout stock = (LinearLayout) findViewById(R.id.idSeedStock); stock.removeAllViews(); for (int i = 0; i < mSeed.getNbSachet(); i++) { ImageView seedbag = new ImageView(mContext); seedbag.setImageDrawable(mContext.getResources().getDrawable(R.drawable.seed_bag)); // seedbag.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_planning_sow)); LayoutParams params = new LinearLayout.LayoutParams(30, 30); seedbag.setLayoutParams(params); stock.addView(seedbag, i); } if (mSeed.getLanguage() != null && !"".equals(mSeed.getLanguage())) { ImageView flag = (ImageView) findViewById(R.id.IdSeedLanguage); int flagRessource = getResources() .getIdentifier("org.gots:drawable/" + mSeed.getLanguage().toLowerCase(), null, null); flag.setImageResource(flagRessource); } likeCount = (TextView) findViewById(R.id.textSeedLike); like = (ImageView) findViewById(R.id.ImageSeedLike); displayLikeStatus(mSeed.getLikeStatus()); if (mSeed.getUUID() == null) like.setVisibility(View.GONE); like.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AsyncTask<Void, Void, LikeStatus>() { GotsException exception = null; @Override protected LikeStatus doInBackground(Void... params) { GotsSeedManager manager = GotsSeedManager.getInstance().initIfNew(mContext); try { return manager.like(mSeed, mSeed.getLikeStatus().getUserLikeStatus() == 1); } catch (GotsException e) { exception = e; return null; } catch (Exception e) { Log.e(getClass().getName(), "" + e.getMessage(), e); return null; } } protected void onPostExecute(LikeStatus result) { if (result == null && exception != null) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); // set title alertDialogBuilder.setTitle(exception.getMessage()); alertDialogBuilder.setMessage(exception.getMessageDescription()).setCancelable(false) .setPositiveButton(mContext.getResources().getString(R.string.login_connect), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Intent loginIntent = new Intent(mContext, LoginDialogFragment.class); // mContext.startActivity(loginIntent); LoginDialogFragment dialogFragment = new LoginDialogFragment(); dialogFragment.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog); dialogFragment.show(((FragmentActivity) mContext) .getSupportFragmentManager(), ""); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); return; } mSeed.setLikeStatus(result); displayLikeStatus(result); mContext.sendBroadcast(new Intent(BroadCastMessages.SEED_DISPLAYLIST)); }; }.execute(); } }); }
From source file:org.onebusaway.android.report.ui.SimpleArrivalListFragment.java
private void loadArrivalList(ObaArrivalInfo[] info, final ObaReferences refs, long currentTime) { LinearLayout contentLayout = (LinearLayout) getActivity().findViewById(R.id.simple_arrival_content); contentLayout.removeAllViews(); ArrayList<ArrivalInfo> arrivalInfos = ArrivalInfoUtils.convertObaArrivalInfo(getActivity(), info, new ArrayList<String>(), currentTime, false); for (ArrivalInfo stopInfo : arrivalInfos) { final ObaArrivalInfo arrivalInfo = stopInfo.getInfo(); LayoutInflater inflater = LayoutInflater.from(getActivity()); LinearLayout view = (LinearLayout) inflater.inflate(R.layout.arrivals_list_item, null, false); view.setBackgroundColor(getResources().getColor(R.color.material_background)); TextView route = (TextView) view.findViewById(R.id.route); TextView destination = (TextView) view.findViewById(R.id.destination); TextView time = (TextView) view.findViewById(R.id.time); TextView status = (TextView) view.findViewById(R.id.status); TextView etaView = (TextView) view.findViewById(R.id.eta); TextView minView = (TextView) view.findViewById(R.id.eta_min); ViewGroup realtimeView = (ViewGroup) view.findViewById(R.id.eta_realtime_indicator); view.findViewById(R.id.more_horizontal).setVisibility(View.INVISIBLE); view.findViewById(R.id.route_favorite).setVisibility(View.INVISIBLE); String routeShortName = arrivalInfo.getShortName(); route.setText(routeShortName);/* w w w . ja v a2s . c om*/ UIUtils.maybeShrinkRouteName(getActivity(), route, routeShortName); destination.setText(UIUtils.formatDisplayText(arrivalInfo.getHeadsign())); status.setText(stopInfo.getStatusText()); long eta = stopInfo.getEta(); if (eta == 0) { etaView.setText(R.string.stop_info_eta_now); minView.setVisibility(View.GONE); } else { etaView.setText(String.valueOf(eta)); minView.setVisibility(View.VISIBLE); } status.setBackgroundResource(R.drawable.round_corners_style_b_status); GradientDrawable d = (GradientDrawable) status.getBackground(); Integer colorCode = stopInfo.getColor(); int color = getActivity().getResources().getColor(colorCode); if (stopInfo.getPredicted()) { // Show real-time indicator UIUtils.setRealtimeIndicatorColorByResourceCode(realtimeView, colorCode, android.R.color.transparent); realtimeView.setVisibility(View.VISIBLE); } else { realtimeView.setVisibility(View.INVISIBLE); } etaView.setTextColor(color); minView.setTextColor(color); d.setColor(color); // Set padding on status view int pSides = UIUtils.dpToPixels(getActivity(), 5); int pTopBottom = UIUtils.dpToPixels(getActivity(), 2); status.setPadding(pSides, pTopBottom, pSides, pTopBottom); time.setText(DateUtils.formatDateTime(getActivity(), stopInfo.getDisplayTime(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT)); View reminder = view.findViewById(R.id.reminder); reminder.setVisibility(View.GONE); contentLayout.addView(view); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String agencyName = findAgencyNameByRouteId(refs, arrivalInfo.getRouteId()); mCallback.onArrivalItemClicked(arrivalInfo, agencyName); } }); } }
From source file:com.todoroo.astrid.files.FilesControlSet.java
@Override protected void afterInflate() { LinearLayout fileList = (LinearLayout) getDialogView().findViewById(R.id.files_list); final LinearLayout finalList = fileList; fileList.removeAllViews(); LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); for (final TaskAttachment m : files) { final View fileRow = inflater.inflate(R.layout.file_row, null); setUpFileRow(m, fileRow, fileList, lp); View name = fileRow.findViewById(R.id.file_text); View clearFile = fileRow.findViewById(R.id.remove_file); name.setOnClickListener(new OnClickListener() { @Override//from w w w. ja v a 2 s . c o m public void onClick(View v) { showFile(m); } }); clearFile.setVisibility(View.VISIBLE); clearFile.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialogBuilder.newMessageDialog(R.string.premium_remove_file_confirm) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (RemoteModel.isValidUuid(m.getUUID())) { // TODO: delete m.setDeletedAt(DateUtilities.now()); taskAttachmentDao.saveExisting(m); } else { taskAttachmentDao.delete(m.getId()); } if (m.containsNonNullValue(TaskAttachment.FILE_PATH)) { File f = new File(m.getFilePath()); f.delete(); } files.remove(m); refreshDisplayView(); finalList.removeView(fileRow); } }).setNegativeButton(android.R.string.cancel, null).show(); } }); } }
From source file:io.indy.drone.fragment.StrikeDetailFragment.java
private void attachAppropriateView(LinearLayout rootView) { rootView.removeAllViews(); // choose layout based on amount of text in strike String summary = mStrike.getBijSummaryShort(); if (summary.length() < 280 || mAlwaysUseFlex) { ifd("full view " + summary.length()); rootView.addView(mFlexLayout);//from w w w . jav a 2 s . c om } else { ifd("half view " + summary.length()); rootView.addView(mHalfLayout); } }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentProduct.java
/** * * @param inflater/*from w w w. j a v a 2 s. c om*/ * @param container * @param savedInstanceState * @return */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.dagvergunning_fragment_product, container, false); // bind the elements to the view ButterKnife.bind(this, view); // get the producten from the sharedprefs and create the product selectors SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); String producten = settings .getString(getContext().getString(R.string.sharedpreferences_key_markt_producten), null); if (producten != null) { // split comma-separated string into list with product strings List<String> productList = Arrays.asList(producten.split(",")); if (productList.size() > 0) { String[] productKeys = getResources().getStringArray(R.array.array_product_key); String[] productTypes = getResources().getStringArray(R.array.array_product_type); String[] productTitles = getResources().getStringArray(R.array.array_product_title); // inflate the producten placeholder view LinearLayout placeholderLayout = (LinearLayout) view.findViewById(R.id.producten_placeholder); if (placeholderLayout != null) { placeholderLayout.removeAllViews(); LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // add multiple product item views to the placeholder view for (int i = 0; i < productList.size(); i++) { // get a resource id for the product int id = Utility.getResId("product_" + productList.get(i), R.id.class); if (id != -1) { // get the corresponding product type based on the productlist item value String productType = ""; for (int j = 0; j < productKeys.length; j++) { if (productKeys[j].equals(productList.get(i))) { productType = productTypes[j]; } } // get the product item layout depending on the product type View childLayout = null; if (productType.equals("integer")) { childLayout = layoutInflater.inflate(R.layout.dagvergunning_product_item_count, null); } else if (productType.equals("boolean")) { childLayout = layoutInflater.inflate(R.layout.dagvergunning_product_item_toggle, null); } if (childLayout != null) { childLayout.setId(id); // get the corresponding product title based on the productlist item value String productTitle = ""; for (int j = 0; j < productKeys.length; j++) { if (productKeys[j].equals(productList.get(i))) { productTitle = productTitles[j]; } } // set product name TextView productNameText = (TextView) childLayout.findViewById(R.id.product_name); productNameText.setText(productTitle); // if product type is integer add click handlers to +- buttons if (productType.equals("integer")) { // set onclickhandler on the - buttons to decrease the value of the product_count textview Button countDownButton = (Button) childLayout .findViewById(R.id.product_count_down); countDownButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { changeProductCountText(v, false); } }); // set onclickhandler on the + buttons to increase the value of the product_count textview Button countUpButton = (Button) childLayout.findViewById(R.id.product_count_up); countUpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { changeProductCountText(v, true); } }); } // add view and move cursor to next product placeholderLayout.addView(childLayout, i); } } } } } } return view; }
From source file:com.nadmm.airports.wx.PirepFragment.java
protected void showError(String error) { View detail = findViewById(R.id.wx_detail_layout); detail.setVisibility(View.GONE); LinearLayout layout = (LinearLayout) findViewById(R.id.wx_status_layout); layout.removeAllViews(); layout.setVisibility(View.GONE); TextView tv = (TextView) findViewById(R.id.status_msg); tv.setVisibility(View.VISIBLE); tv.setText(error);/*from w w w . j a v a 2 s.c o m*/ View title = findViewById(R.id.wx_title_layout); title.setVisibility(View.GONE); stopRefreshAnimation(); setContentShown(true); return; }
From source file:com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity.java
private void recreateEditingUi() { IControllerFactory controllerFactory = BasicControllerFactory.getInstance(); mFieldController = controllerFactory.createControllerForField(mField); if (mFieldController == null) { Timber.d("Field controller creation failed"); return;//w ww .j a v a2s. c om } // Request permission to record if audio field if (mField instanceof AudioField && ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.RECORD_AUDIO }, REQUEST_AUDIO_PERMISSION); return; } mFieldController.setField(mField); mFieldController.setFieldIndex(mFieldIndex); mFieldController.setNote(mNote); mFieldController.setEditingActivity(this); LinearLayout linearLayout = (LinearLayout) findViewById(R.id.LinearLayoutInScrollViewFieldEdit); linearLayout.removeAllViews(); mFieldController.createUI(this, linearLayout); }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentOverzicht.java
/** * Populate the koopman fragment item details item when the loader has finished * @param loader the cursor loader// www . ja v a 2s. c o m * @param data data object containing one or more koopman rows with joined sollicitatie data */ @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { // get the markt id from the sharedprefs SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); int marktId = settings.getInt(getContext().getString(R.string.sharedpreferences_key_markt_id), 0); // koopman photo Glide.with(getContext()) .load(data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_FOTO_URL))) .error(R.drawable.no_koopman_image).into(mKoopmanFotoImage); // koopman naam String naam = data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_VOORLETTERS)) + " " + data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ACHTERNAAM)); mKoopmanVoorlettersAchternaamText.setText(naam); // koopman erkenningsnummer String erkenningsnummer = data .getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ERKENNINGSNUMMER)); mErkenningsnummerText.setText(erkenningsnummer); // koopman sollicitaties View view = getView(); if (view != null) { LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout placeholderLayout = (LinearLayout) view.findViewById(R.id.sollicitaties_placeholder); placeholderLayout.removeAllViews(); // add multiple markt sollicitatie views to the koopman items while (!data.isAfterLast()) { // inflate sollicitatie layout and populate its view items View childLayout = layoutInflater.inflate(R.layout.dagvergunning_koopman_item_sollicitatie, null); // highlight the sollicitatie for the current markt if (data.getCount() > 1 && marktId > 0 && marktId == data .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) { childLayout.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary)); } // markt afkorting String marktAfkorting = data .getString(data.getColumnIndex(MakkelijkeMarktProvider.Markt.COL_AFKORTING)); TextView marktAfkortingText = (TextView) childLayout .findViewById(R.id.sollicitatie_markt_afkorting); marktAfkortingText.setText(marktAfkorting); // koopman sollicitatienummer String sollicitatienummer = data.getString( data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_SOLLICITATIE_NUMMER)); TextView sollicitatienummerText = (TextView) childLayout .findViewById(R.id.sollicitatie_sollicitatie_nummer); sollicitatienummerText.setText(sollicitatienummer); // koopman sollicitatie status String sollicitatieStatus = data.getString(data.getColumnIndex("sollicitatie_status")); TextView sollicitatieStatusText = (TextView) childLayout.findViewById(R.id.sollicitatie_status); sollicitatieStatusText.setText(sollicitatieStatus); if (sollicitatieStatus != null && !sollicitatieStatus.equals("?") && !sollicitatieStatus.equals("")) { sollicitatieStatusText .setTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); sollicitatieStatusText.setBackgroundColor(ContextCompat.getColor(getContext(), Utility.getSollicitatieStatusColor(getContext(), sollicitatieStatus))); } // add view and move cursor to next placeholderLayout.addView(childLayout, data.getPosition()); data.moveToNext(); } } } }
From source file:com.gh4a.fragment.UserFragment.java
public void fillTopRepos(Collection<Repository> topRepos) { LinearLayout ll = (LinearLayout) mContentView.findViewById(R.id.ll_top_repos); ll.removeAllViews(); LayoutInflater inflater = getLayoutInflater(null); if (topRepos != null) { for (Repository repo : topRepos) { View rowView = inflater.inflate(R.layout.top_repo, null); rowView.setOnClickListener(this); rowView.setTag(repo);/*from w w w . j a va2 s. c om*/ TextView tvTitle = (TextView) rowView.findViewById(R.id.tv_title); tvTitle.setText(repo.getOwner().getLogin() + "/" + repo.getName()); TextView tvDesc = (TextView) rowView.findViewById(R.id.tv_desc); if (!StringUtils.isBlank(repo.getDescription())) { tvDesc.setVisibility(View.VISIBLE); tvDesc.setText(repo.getDescription()); } else { tvDesc.setVisibility(View.GONE); } TextView tvForks = (TextView) rowView.findViewById(R.id.tv_forks); tvForks.setText(String.valueOf(repo.getForks())); TextView tvStars = (TextView) rowView.findViewById(R.id.tv_stars); tvStars.setText(String.valueOf(repo.getWatchers())); ll.addView(rowView); } } View btnMore = getView().findViewById(R.id.btn_repos); if (topRepos != null && !topRepos.isEmpty()) { btnMore.setOnClickListener(this); btnMore.setVisibility(View.VISIBLE); } else { TextView hintView = (TextView) inflater.inflate(R.layout.hint_view, ll, false); hintView.setText(R.string.user_no_repos); ll.addView(hintView); } getView().findViewById(R.id.pb_top_repos).setVisibility(View.GONE); getView().findViewById(R.id.ll_top_repos).setVisibility(View.VISIBLE); }
From source file:com.nadmm.airports.wx.PirepFragment.java
protected void showPirep(Intent intent) { Pirep pirep = (Pirep) intent.getSerializableExtra(NoaaService.RESULT); LinearLayout layout = (LinearLayout) findViewById(R.id.pirep_entries_layout); layout.removeAllViews(); if (!pirep.entries.isEmpty()) { TextView tv = (TextView) findViewById(R.id.pirep_title_msg); tv.setText(String.format("%d PIREPs reported within %d NM of %s during last %d hours", pirep.entries.size(), PIREP_RADIUS_NM, mStationId, PIREP_HOURS_BEFORE)); for (PirepEntry entry : pirep.entries) { showPirepEntry(layout, entry); }/*from ww w. j av a2 s. co m*/ } else { TextView tv = (TextView) findViewById(R.id.pirep_title_msg); tv.setText(String.format("No PIREPs reported within %d NM of %s in last %d hours", PIREP_RADIUS_NM, mStationId, PIREP_HOURS_BEFORE)); } TextView tv = (TextView) findViewById(R.id.wx_fetch_time); tv.setText("Fetched on " + TimeUtils.formatDateTime(getActivity(), pirep.fetchTime)); tv.setVisibility(View.VISIBLE); stopRefreshAnimation(); setFragmentContentShown(true); }