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.joanzapata.android.BasePagerAdapter.java
@Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView(mViews.get(position)); }
From source file:am.util.viewpager.adapter.RecyclePagerAdapter.java
public final void destroyItem(ViewGroup container, int position, @NonNull Object object) { //noinspection unchecked VH holder = (VH) object;// w w w . j a v a 2 s . c om container.removeView(holder.itemView); holder.isRecycled = true; holder.mPosition = POSITION_NONE; int viewType = getItemViewType(position); ArrayList<VH> recycleHolders = holderSparse.get(viewType, new ArrayList<VH>()); recycleHolders.add(holder); holderSparse.put(viewType, recycleHolders); onViewRecycled(holder); }
From source file:com.community.yuequ.bottombar.BottomBarBadge.java
void removeFromTab(BottomBarTab tab) { FrameLayout badgeAndTabContainer = (FrameLayout) getParent(); ViewGroup originalTabContainer = (ViewGroup) badgeAndTabContainer.getParent(); badgeAndTabContainer.removeView(tab); originalTabContainer.removeView(badgeAndTabContainer); originalTabContainer.addView(tab, tab.getIndexInTabContainer()); }
From source file:com.daniel.lupianez.casares.LayoutPagerAdapter.java
@Override public void destroyItem(ViewGroup container, int position, Object object) { //When destroying the item, remove it from the view group View view = (View) object; container.removeView(view); }
From source file:jp.mydns.sys1yagi.android.viewsticker.ViewSticker.java
private ViewGroup wrap(final View target, final ScrollView monitored, final ViewGroup container) { ViewGroup parent = (ViewGroup) target.getParent(); int index = parent.indexOfChild(target); parent.removeView(target); final int[] dimension = new int[2]; FrameLayout stuffing = new FrameLayout(target.getContext()) { ViewTreeObserver.OnScrollChangedListener mObserver = new ViewTreeObserver.OnScrollChangedListener() { @Override/*from w w w . j av a 2 s. c om*/ public void onScrollChanged() { monitored.getLocationOnScreen(dimension); int offset = dimension[1]; getLocationOnScreen(dimension); int top = dimension[1] - offset; offset(target, top); if (top < 0 && indexOfChild(target) >= 0) { removeView(target); container.addView(target); } else if (top >= 0 && indexOfChild(target) < 0) { container.removeView(target); addView(target); } } }; @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec); int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec); measureChildWithMargins(target, widthMeasureSpec, 0, heightMeasureSpec, 0); setMeasuredDimension(widthSpecSize, heightSpecSize + target.getMeasuredHeight()); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); monitored.getViewTreeObserver().addOnScrollChangedListener(mObserver); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); monitored.getViewTreeObserver().removeOnScrollChangedListener(mObserver); } }; stuffing.addView(target); parent.addView(stuffing, index); return stuffing; }
From source file:info.papdt.blacklight.ui.common.AbsActivity.java
@TargetApi(21) private void swipeInit() { // Replace the view first LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); SlidingPaneLayout v = (SlidingPaneLayout) inflater.inflate(R.layout.swipe_decor_wrapper, null); final ViewGroup frame = (ViewGroup) v.findViewById(R.id.swipe_container); View swipeView = getSwipeView(); ViewGroup decor = (ViewGroup) swipeView.getParent(); ViewGroup.LayoutParams params = swipeView.getLayoutParams(); decor.removeView(swipeView); frame.addView(swipeView);/*w ww. j a v a2s . c o m*/ decor.addView(v, params); decor.setBackgroundColor(0); // Elevation if (Build.VERSION.SDK_INT >= 21) { frame.setElevation(11.8f); } else { v.setShadowResource(R.drawable.panel_shadow); } // Swipe gesture configurations v.setSliderFadeColor(0); v.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { @Override public void onPanelSlide(View v, float percent) { getWindow().getDecorView().setAlpha(1.0f - percent); } @Override public void onPanelOpened(View p1) { finish(); } @Override public void onPanelClosed(View p1) { } }); // Adjust window color getWindow().setBackgroundDrawable(new ColorDrawable(0)); }
From source file:com.example.ccrvlz.dcp.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (null != rootView) { ViewGroup parent = (ViewGroup) rootView.getParent(); if (null != parent) { parent.removeView(rootView); }//from www . java 2 s. c o m } else { rootView = inflater.inflate(R.layout.dcp_list_layout, container, false); //XlistView listV = (XListView) rootView.findViewById(R.id.dcp_list); listV.setPullLoadEnable(true); adapter = new AdapterForDcpList(this.getActivity()); listV.setAdapter(adapter); //XlistView loadData(adapter.getResults()); //item listV.setXListViewListener(this); listV.setOnItemClickListener(this); } return rootView; }
From source file:cn.zhangls.android.weibo.common.SwipeActivity.java
/** * ?//w w w . ja va 2 s. c om */ private void initSwipeBackFinish() { SlidingPaneLayout slidingPaneLayout = new SlidingPaneLayout(this); //???mOverhangSize0mOverhangSize????? //32dp?0 try { // Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize"); f_overHang.setAccessible(true); f_overHang.set(slidingPaneLayout, 0); } catch (Exception e) { e.printStackTrace(); } slidingPaneLayout.setPanelSlideListener(this); slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent)); View leftView = new View(this); leftView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); slidingPaneLayout.addView(leftView, 0); ViewGroup decor = (ViewGroup) getWindow().getDecorView(); ViewGroup decorChild = (ViewGroup) decor.getChildAt(0); decorChild.setBackgroundColor(getResources().getColor(android.R.color.white)); decor.removeView(decorChild); decor.addView(slidingPaneLayout); slidingPaneLayout.addView(decorChild, 1); }
From source file:com.grarak.kerneladiutor.views.recyclerview.CardView.java
private void setupLayout() { if (mLayout != null) { mLayout.removeAllViews();//from w w w . ja va 2s. c om for (final RecyclerViewItem item : mItems) { View view; if (mViews.containsKey(item)) { view = mViews.get(item); } else { mViews.put(item, view = LayoutInflater.from(mActivity).inflate(item.getLayoutRes(), null, false)); } ViewGroup viewGroup = (ViewGroup) view.getParent(); if (viewGroup != null) { viewGroup.removeView(view); } item.setOnViewChangeListener(getOnViewChangedListener()); item.onCreateView(view); mLayout.addView(view); } } }
From source file:com.barcamppenang2014.tabfragment.HomeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (scrollView != null) { ViewGroup parent = (ViewGroup) scrollView.getParent(); if (parent != null) parent.removeView(scrollView); }//from w ww . j a va2 s . c om scrollView = (ScrollView) inflater.inflate(R.layout.home_layout, container, false); LinearLayout linearLayout = (LinearLayout) scrollView.findViewById(R.id.home_linear_layout); // linearLayout.setBackgroundColor(Color.WHITE); mTextViewDay = (TextView) linearLayout.findViewById(R.id.count_down_day); mTextViewHour = (TextView) linearLayout.findViewById(R.id.count_down_hour); mImageViewClickMe = (Button) linearLayout.findViewById(R.id.map_fullscreen_button); mImageViewClickMe.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getActivity() == null) return; MainActivity fca = (MainActivity) getActivity(); fca.getSupportActionBar().setDisplayHomeAsUpEnabled(true); fca.switchContent(new MapFragment()); } }); // mTextView.setBackgroundResource(R.drawable.info_countdown); @SuppressWarnings("deprecation") Date date = new Date(114, 4, 17, 9, 0, 0); // 2014/May/17 9am // year the year, 0 is 1900. // month the month, 0 - 11. // day the day of the month, 1 - 31. long dtMili = System.currentTimeMillis(); Date dateNow = new Date(dtMili); long remain = date.getTime() - dateNow.getTime(); new CountDownTimer(remain, 1000) { public void onTick(long millisUntilFinished) { //mTextView.setText("seconds remaining: " + millisUntilFinished/ 1000); String day = timeDay(millisUntilFinished / 1000); String hour = timeHour(millisUntilFinished / 1000); mTextViewDay.setText(day); mTextViewHour.setText(hour); /*if(Integer.parseInt(day)>9 && Integer.parseInt(hour)<=9){ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mTextViewDay.getLayoutParams(); params.rightMargin = 85; mTextViewDay.setLayoutParams(params); } if(Integer.parseInt(day)<=9 && Integer.parseInt(hour)<=9 ){ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mTextViewDay.getLayoutParams(); params.rightMargin = 145; mTextViewDay.setLayoutParams(params); } if(Integer.parseInt(day)<=9 && Integer.parseInt(hour)>9 ){ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mTextViewDay.getLayoutParams(); params.rightMargin = 125; mTextViewDay.setLayoutParams(params); }*/ } public void onFinish() { // mTextView.setText("done!"); } }.start(); return scrollView; }