List of usage examples for android.view ViewGroup removeView
@Override public void removeView(View view)
Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.
From source file:com.harlan.jxust.ui.view.bottombar.BottomBarBadge.java
protected BottomBarBadge(Context context, int position, final View tabToAddTo, // Rhyming accidentally! That's a Smoove Move! int backgroundColor) { super(context); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); setLayoutParams(params);/* ww w. j ava 2 s . com*/ setGravity(Gravity.CENTER); MiscUtils.setTextAppearance(this, R.style.BB_BottomBarBadge_Text); int three = MiscUtils.dpToPixel(context, 3); ShapeDrawable backgroundCircle = BadgeCircle.make(three * 3, backgroundColor); setPadding(three, three, three, three); setBackgroundCompat(backgroundCircle); FrameLayout container = new FrameLayout(context); container.setLayoutParams(params); ViewGroup parent = (ViewGroup) tabToAddTo.getParent(); parent.removeView(tabToAddTo); container.addView(tabToAddTo); container.addView(this); parent.addView(container, position); container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { adjustPositionAndSize(tabToAddTo); } }); }
From source file:jahirfiquitiva.iconshowcase.fragments.FAQsFragment.java
@Override public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { context = getActivity();/*from www. j av a 2s . c om*/ mPrefs = new Preferences(context); if (layout != null) { ViewGroup parent = (ViewGroup) layout.getParent(); if (parent != null) { parent.removeView(layout); } } try { layout = (ViewGroup) inflater.inflate(R.layout.faqs_section, container, false); } catch (InflateException e) { //Do nothing } String[] questions = getResources().getStringArray(R.array.questions); String[] answers = getResources().getStringArray(R.array.answers); List<FAQsItem> faqs = new ArrayList<>(); for (int i = 0; i < questions.length; i++) { FAQsItem item = new FAQsItem(questions[i], answers[i]); faqs.add(item); } int cardsSpacing = getResources().getDimensionPixelSize(R.dimen.dividers_height); RecyclerView faqsList = (RecyclerView) layout.findViewById(R.id.faqs_list); FAQsAdapter faqsAdapter = new FAQsAdapter(faqs, getActivity()); boolean listsCards; if (context.getResources().getBoolean(R.bool.dev_options)) { listsCards = mPrefs.getDevListsCards(); } else { listsCards = context.getResources().getBoolean(R.bool.faqs_cards); } if (listsCards) { faqsList.setLayoutManager(new GridLayoutManager(getActivity(), 1)); faqsList.addItemDecoration(new GridSpacingItemDecoration(1, getActivity().getResources().getDimensionPixelSize(R.dimen.cards_margin), true)); } else { faqsList.setLayoutManager(new LinearLayoutManager(getActivity())); faqsList.addItemDecoration(new DividerItemDecoration(getActivity(), null, cardsSpacing, false, false)); } faqsList.setItemAnimator(new DefaultItemAnimator()); faqsList.setHasFixedSize(true); faqsList.setAdapter(faqsAdapter); RecyclerFastScroller fastScroller = (RecyclerFastScroller) layout.findViewById(R.id.rvFastScroller); fastScroller.attachRecyclerView(faqsList); return layout; }
From source file:cn.chenzhongjin.eventbus.sample.ui.base.BaseFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = (BaseActivity) getActivity(); if (null != view) { ViewGroup parent = (ViewGroup) view.getParent(); if (null != parent) { parent.removeView(view); }//from w w w. j a va 2 s . co m } else { view = inflater.inflate(getLayoutId(), container, false); } return view; }
From source file:net.pejici.easydice.pageradapter.DieHandListAdapter.java
@Override public void destroyItem(ViewGroup container, int position, Object object) { DieViewModelPair p = (DieViewModelPair) object; p.view.setHand(null);/*from ww w. j a va 2 s.c om*/ queue.add(p.view); container.removeView(p.view); }
From source file:com.outsystemscloud.andrevieira.secureDevice.java
private void checkDevice() { boolean _isDeviceRooted = isDeviceRooted(); boolean _isPasscodeSet = doesDeviceHaveSecuritySetup(this.cordova.getActivity()); if (_isDeviceRooted || !_isPasscodeSet) { // Remove View View v = this.view.getView(); ViewGroup viewParent = (ViewGroup) v.getParent(); viewParent.removeView(v); // Show message and quit Application app = cordova.getActivity().getApplication(); String package_name = app.getPackageName(); Resources resources = app.getResources(); String message = resources.getString(resources.getIdentifier("message", "string", package_name)); String label = resources.getString(resources.getIdentifier("label", "string", package_name)); this.alert(message, label); }/* www .jav a2s . com*/ }
From source file:com.wms.opensource.images3android.activity.ImageListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (layout != null) { ViewGroup parent = (ViewGroup) layout.getParent(); parent.removeView(layout); return layout; }/* w w w . ja v a 2s . c o m*/ if (listView == null) { layout = new RelativeLayout(getActivity()); listView = new ListView(getActivity()); layout.addView(listView); progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge); // Center a view in relative layout RelativeLayout.LayoutParams progressBarParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarParams.addRule(RelativeLayout.CENTER_IN_PARENT); progressBar.setLayoutParams(progressBarParams); progressBar.setVisibility(View.INVISIBLE); layout.addView(progressBar); // Before reloading videos, display videos if they have been saved before String imagesFilePath = ""; imagesFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameUtil.getImagesPersistFileName(getString(R.string.imagePlantId), page); boolean imagesFileExists = FileUtil.fileExist(imagesFilePath); if (imagesFileExists) { loadCachedImagesTask = new LoadCachedImagesTask(getActivity(), loadImagesHandler, progressBar, getActivity().getString(R.string.ImageS3ServiceURL), getActivity().getString(R.string.imagePlantId), page); loadCachedImagesTask.execute(); } else { NetworkStatus networkStatus = NetworkUtil.getNetworkStatus(getActivity()); if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED) || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) { String pageToken = page == 1 ? "" : ImageListFragmentActivity.pageTokens.get(page - 1); loadImagesTask = new LoadImagesTask(getActivity(), loadImagesHandler, getActivity().getString(R.string.ImageS3ServiceURL), getActivity().getString(R.string.imagePlantId), pageToken, page); loadImagesTask.execute(); } else { Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show(); } } } return layout; }
From source file:com.android.gallery3d.v5.filtershow.editors.EditorPanel.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FilterShowActivity activity = (FilterShowActivity) getActivity(); if (mMainView != null) { if (mMainView.getParent() != null) { ViewGroup parent = (ViewGroup) mMainView.getParent(); parent.removeView(mMainView); }// www . jav a 2 s. co m showImageStatePanel(activity.isShowingImageStatePanel()); return mMainView; } mMainView = (LinearLayout) inflater.inflate(R.layout.filtershow_editor_panel, null); resetPanel(); return mMainView; }
From source file:com.jecelyin.common.adapter.ViewPagerAdapter.java
/** * Remove a page for the given position. * * @param container The containing View from which the page will be removed. * @param position The page position to be removed. * @param view The same object that was returned by instantiateItem(View, int). *//*from w ww . j a v a 2s. c o m*/ @Override public void destroyItem(ViewGroup container, int position, Object view) { L.d("remove page %d", position); if (mCurrentPrimaryItem == view) mCurrentPrimaryItem = null; container.removeView((View) view); }
From source file:com.jana.android.ui.impl.viewmodel.ImagePagerAdapter.java
@Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); mImageList.set(position, null);//from w w w . ja v a 2 s.co m }
From source file:bottombar.BottomBarBadge.java
void removeFromTab(BottomBarTab tab) { BadgeContainer badgeAndTabContainer = (BadgeContainer) getParent(); ViewGroup originalTabContainer = (ViewGroup) badgeAndTabContainer.getParent(); badgeAndTabContainer.removeView(tab); originalTabContainer.removeView(badgeAndTabContainer); originalTabContainer.addView(tab, tab.getIndexInTabContainer()); }