Example usage for android.view ViewGroup removeView

List of usage examples for android.view ViewGroup removeView

Introduction

In this page you can find the example usage for android.view ViewGroup removeView.

Prototype

@Override
public void removeView(View view) 

Source Link

Document

Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.

Usage

From source file:com.actionbarsherlock.internal.widget.IcsListPopupWindow.java

public void dismiss() {
    mPopup.dismiss();/* www.  j a  va 2  s  . c  o m*/
    if (mPromptView != null) {
        final ViewParent parent = mPromptView.getParent();
        if (parent instanceof ViewGroup) {
            final ViewGroup group = (ViewGroup) parent;
            group.removeView(mPromptView);
        }
    }
    mPopup.setContentView(null);
    mDropDownList = null;
    mHandler.removeCallbacks(mResizePopupRunnable);
}

From source file:edu.cens.loci.ui.widget.GenericEditorView.java

/** {@inheritDoc} */
public void onClick(View v) {

    //Log.i(TAG, "onClick");

    switch (v.getId()) {
    case R.id.edit_delete: {

        //Log.i(TAG, "edit_delete");

        // Keep around in model, but mark as deleted
        mEntry.markDeleted();/*from   www.  j  a  va2s. c  o  m*/

        // Remove editor from parent view
        final ViewGroup parent = (ViewGroup) getParent();
        parent.removeView(this);

        if (mListener != null) {
            // Notify listener when present
            mListener.onDeleted(this);
        }
        break;
    }
    case R.id.edit_more:
    case R.id.edit_less: {
        //Log.i(TAG, "edit_more_less");           
        mHideOptional = !mHideOptional;
        rebuildValues();
        break;
    }
    default:
        //Log.i(TAG, "default");           

        if (mWifiFieldButtonId == v.getId()) {
            //Log.i("GenericEditorView", "onClick(): wifi button. " + v.getId());
            createWifiDialog();
        }
    }
}

From source file:com.lsjwzh.widget.recyclerviewpagerdeomo.ViewPagerFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final Activity activity = getActivity();

    mToast = Toast.makeText(activity, "", Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.CENTER, 0, 0);

    mViewPager = (ViewPager) view.findViewById(R.id.list);
    mViewPager.setAdapter(new PagerAdapter() {
        @Override//from   ww w  .j  a  v  a 2s .c o  m
        public int getCount() {
            return 100;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            final View view = LayoutInflater.from(getActivity()).inflate(R.layout.item, container, false);
            ((TextView) view.findViewById(R.id.title)).setText(position + "");
            view.setTag("" + position);
            container.addView(view);
            return view;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            if (object != null && object instanceof View) {
                container.removeView((View) object);
            }
        }

        @Override
        public int getItemPosition(Object object) {
            if (object instanceof View) {
                return Integer.valueOf(((View) object).getTag().toString());
            }
            return super.getItemPosition(object);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }
    });
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {
            updateState(state);
        }
    });

    mStateText = (TextView) view.getRootView().findViewById(R.id.state);
    updateState(RecyclerView.SCROLL_STATE_IDLE);
}

From source file:com.gitstudy.rili.liarbry.YearViewSelectLayout.java

void setup(CalendarViewDelegate delegate) {
    this.mDelegate = delegate;
    this.mYearCount = mDelegate.getMaxYear() - mDelegate.getMinYear() + 1;
    setAdapter(new PagerAdapter() {
        @Override//from   ww  w .  j  ava  2  s.c o  m
        public int getCount() {
            return mYearCount;
        }

        @Override
        public int getItemPosition(Object object) {
            return isUpdateYearView ? POSITION_NONE : super.getItemPosition(object);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            YearRecyclerView view = new YearRecyclerView(getContext());
            container.addView(view);
            view.setup(mDelegate);
            view.setOnMonthSelectedListener(mListener);
            view.init(position + mDelegate.getMinYear());
            return view;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            if (object instanceof YearRecyclerView)
                container.removeView((YearRecyclerView) object);
        }
    });
    setCurrentItem(mDelegate.getCurrentDay().getYear() - mDelegate.getMinYear());
}

From source file:com.miuhouse.yourcompany.student.view.widget.date.datepicker.DayPickerPagerAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    final ViewHolder holder = (ViewHolder) object;
    container.removeView(holder.container);
    mItems.remove(position);/*w w  w. ja va2 s  . c  om*/
    rangeHashMap.clear();
}

From source file:com.aboveware.common.crouton.Manager.java

/**
 * Removes the {@link Crouton}'s view after it's display
 * durationInMilliseconds./*from   w ww.j ava  2 s  .c om*/
 *
 * @param crouton
 *          The {@link Crouton} added to a {@link ViewGroup} and should be
 *          removed.
 */
private void removeCrouton(Crouton crouton) {
    View croutonView = crouton.getView();
    ViewGroup croutonParentView = (ViewGroup) croutonView.getParent();

    if (croutonParentView != null) {
        croutonView.startAnimation(crouton.getOutAnimation());

        // Remove the Crouton from the queue.
        Crouton removed = croutonQueue.poll();

        // Remove the crouton from the view's parent.
        croutonParentView.removeView(croutonView);
        if (removed != null) {
            removed.detachActivity();
            removed.detachViewGroup();
            if (removed.getLifecycleCallback() != null) {
                removed.getLifecycleCallback().onRemoved();
            }
            removed.detachLifecycleCallback();
        }

        // Send a message to display the next crouton but delay it by the out
        // animation duration to make sure it finishes
        sendMessageDelayed(crouton, Messages.DISPLAY_CROUTON, crouton.getOutAnimation().getDuration());
    }
}

From source file:app.newbee.lib.swipeback.SwipeBackLayout.java

public void attachToActivity(Activity activity) {
    mActivity = activity;//  ww  w.  jav  a 2  s  . c om
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    int background = a.getResourceId(0, 0);
    a.recycle();

    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    setContentView(decorChild);
    decor.addView(this);
}

From source file:com.seal.ui.fragments.StartPageFragment.java

private void iniListener() {

    if (mUIManager != null) {
        mStartListViewAdapter = new ExpandableListViewAdapter(getActivity(), mUIManager);
        mStartListView.setAdapter(mStartListViewAdapter);
        mStartListView.expandGroup(0);/*from w  ww  .ja  va  2 s.  c  o  m*/
        mStartListView.expandGroup(1);
        mStartListView.expandGroup(2);
    }
    futureWeatherGrid.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.weather.com.cn");
        }
    });

    start_viewpager.setAdapter(new PagerAdapter() {
        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            container.addView(views[position]);
            return views[position];
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {

            container.removeView(views[position]);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public int getCount() {
            return views.length;
        }
    });
    start_viewpager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            // TODO Auto-generated method stub
            switch (position) {
            case 0:
                indicator_1.setImageResource(R.drawable.ic_pageindicator_current);
                indicator_2.setImageResource(R.drawable.ic_pageindicator_default);
                break;
            case 1:
                indicator_1.setImageResource(R.drawable.ic_pageindicator_default);
                indicator_2.setImageResource(R.drawable.ic_pageindicator_current);
                break;
            }
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onPageScrollStateChanged(int state) {
            // TODO Auto-generated method stub

        }
    });
    weatherRefresh.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (!TextUtils.isEmpty(currentCity)) {
                getBeautyData(currentCity);
            }
        }
    });
    news.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.toutiao.com");
        }
    });
    nav.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.hao123.com");
        }
    });
    baidu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.baidu.com");
        }
    });
    shipin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.video.baidu.com");
        }
    });
}

From source file:com.hayukleung.app.BaseFragment.java

/**
 * Set the content view to an explicit view. If the content view was installed earlier, the content will be replaced
 * with a new view.//  ww  w .j ava 2  s  . c o  m
 *
 * @param view The desired content to display. Value can't be null.
 * @see #setContentView(int)
 * @see #getContentView()
 */
public void setContentView(View view) {
    ensureContent();
    if (view == null) {
        throw new IllegalArgumentException("Content view can't be null");
    }
    if (mContentContainer instanceof ViewGroup) {
        ViewGroup contentContainer = (ViewGroup) mContentContainer;
        ViewParent contentViewParent = view.getParent();
        if (contentViewParent == null) {
            if (mContentView == null) {
                contentContainer.addView(view);
            } else {
                int index = contentContainer.indexOfChild(mContentView);
                // replace content view
                contentContainer.removeView(mContentView);
                contentContainer.addView(view, index);
            }
        } else if (contentViewParent != mContentContainer) {
            throw new IllegalArgumentException("Content view can't be in other ViewGroup");
        }
        mContentView = view;
    } else {
        throw new IllegalStateException("Can't be used with a custom content view");
    }
}

From source file:osm.custommaps.create.PreviewMapActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Context context = getApplicationContext();
    setContentView(R.layout.createpreview);
    DisplayMetrics dm = getApplicationContext().getResources().getDisplayMetrics();

    MapView mapTryView = (MapView) findViewById(R.id.custom_mapview);
    mapTryView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    // add the mapview to display

    mapView = mapTryView;// www.j  ava2s . c  om
    mapView.setMaxZoomLevel(20);
    mapView.setMinZoomLevel(3);
    mapView.setTileSource(WMSTileSourceFactory.BING_HYBRID);
    ViewParent p = mapView.getParent();
    if (p instanceof ViewGroup) {
        mapView.setMaxZoomLevel(20);
        mapView.setMinZoomLevel(3);
        ViewGroup layout = (ViewGroup) p;
        LayoutParams layoutParams = mapView.getLayoutParams();
        try {
            mPrefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);

            layout.removeView(mapView);
            layout.addView(mapView, layoutParams);
            this.mLocationOverlay = new MyLocationNewOverlay(context, new GpsMyLocationProvider(context),
                    mapView);
            mScaleBarOverlay = new ScaleBarOverlay(context);
            mScaleBarOverlay.setCentred(true);
            mScaleBarOverlay.setScaleBarOffset(dm.widthPixels / 2, 10);

            mapView.setBuiltInZoomControls(true);
            mapView.setMultiTouchControls(true);
            mapView.getController().setZoom(mPrefs.getInt(PREFS_ZOOM_LEVEL, 5));
            mapView.scrollTo(mPrefs.getInt(PREFS_SCROLL_X, 0), mPrefs.getInt(PREFS_SCROLL_Y, 0));

            mLocationOverlay.enableMyLocation();
        } catch (IllegalArgumentException ex) {
            Log.e(CustomMaps.LOG_TAG, "Failed to create a map matching the signature key");
            Button saveButton = (Button) findViewById(R.id.save);
            saveButton.setEnabled(false);
            return;
        }
    }

    prepareUI();
    if (PtSizeFixer.isFixNeeded((Activity) null)) {
        PtSizeFixer.fixView(saveButton.getRootView());
    }
    mapView.setBuiltInZoomControls(true);

    // Create overlay
    String fileName = getIntent().getStringExtra(BITMAP_FILE);
    Bitmap mapImage = ImageHelper.loadImage(fileName, true);
    if (mapImage == null) {
        // Failed to load image, cancel activity
        Toast.makeText(this, R.string.editor_image_load_failed, Toast.LENGTH_LONG).show();
        setResult(RESULT_CANCELED);
        finish();
        return;
    }

    imageOverlay = new WarpedImageOverlay(context, mapImage);

    List<Point> imagePoints;
    imagePoints = new ArrayList<Point>();
    int[] imagePointArray = getIntent().getIntArrayExtra(IMAGE_POINTS);
    for (int i = 0; i + 1 < imagePointArray.length; i += 2) {
        imagePoints.add(new Point(imagePointArray[i], imagePointArray[i + 1]));
    }
    List<IGeoPoint> geoPoints = new ArrayList<IGeoPoint>();
    int[] geoPointArray = getIntent().getIntArrayExtra(TIEPOINTS);
    for (int i = 0; i + 1 < geoPointArray.length; i += 2) {
        geoPoints.add(new GeoPoint(geoPointArray[i], geoPointArray[i + 1]));
    }
    imageOverlay.setTiepoints(imagePoints, geoPoints);
    mapView.getOverlays().add(imageOverlay);

    transparencyBar.setProgress(50);
    imageOverlay.setTransparency(50);

    helpDialogManager = new HelpDialogManager(this, HelpDialogManager.HELP_PREVIEW_CREATE,
            getString(R.string.preview_help));

    // Compute geo location of map image center
    if (!imageOverlay.computeImageWarp(mapView)) {
        mapImageCenter = mapView.getMapCenter(); //TODO Changed to IGeoPoint on the variable
        latSpanE6 = mapView.getLatitudeSpan();
        lonSpanE6 = mapView.getLongitudeSpan();
        return;
    }
    // Get matrix for converting image points to geo points
    imageToGeo = new Matrix();
    imageToGeo.set(imageOverlay.computeImageToGeoMatrix(mapView));
    // Convert center point to geo
    Point center = new Point(mapImage.getWidth() / 2, mapImage.getHeight() / 2);
    mapImageCenter = imageToGeoPoint(imageToGeo, center);
    // Find lat and lon spans
    computeImageCornerGeoPoints();
    int minLatE6 = Integer.MAX_VALUE;
    int maxLatE6 = Integer.MIN_VALUE;
    int minLonE6 = Integer.MAX_VALUE;
    int maxLonE6 = Integer.MIN_VALUE;
    for (IGeoPoint gp : imageCornerGeoPoints) {
        minLatE6 = Math.min(minLatE6, gp.getLatitudeE6());
        maxLatE6 = Math.max(maxLatE6, gp.getLatitudeE6());
        minLonE6 = Math.min(minLonE6, gp.getLongitudeE6());
        maxLonE6 = Math.max(maxLonE6, gp.getLongitudeE6());
    }
    latSpanE6 = maxLatE6 - minLatE6;
    lonSpanE6 = maxLonE6 - minLonE6;
}