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:info.papdt.blacklight.support.Utility.java

public static View addActionViewToCustom(View v, ViewGroup custom) {
    if (v != null) {
        ViewGroup parent = (ViewGroup) v.getParent();
        parent.removeView(v);
        parent.setVisibility(View.GONE);
        ViewGroup.LayoutParams params = parent.getLayoutParams();
        params.width = 0;//from   w  w w  .j av  a  2  s. co m
        params.height = 0;
        parent.setLayoutParams(params);
        custom.addView(v);
    }

    return v;
}

From source file:dev.drsoran.moloko.util.UIUtils.java

public final static void removeTaggedViews(ViewGroup container, String tag) {
    List<View> views = null;

    for (int i = 0, cnt = container.getChildCount(); i < cnt; ++i) {
        final View v = container.getChildAt(i);
        if (v != null && tag.equals(v.getTag())) {
            if (views == null)
                views = new LinkedList<View>();

            views.add(v);/*from w w w.  j av a 2  s.c  om*/
        }
    }

    if (views != null)
        for (View view : views)
            container.removeView(view);
}

From source file:com.hybris.mobile.lib.ui.view.Alert.java

/**
 * Set the icon on the alert/*from  w w w  .  j  a v  a  2s  .  c  om*/
 *
 * @param context       application-specific resources
 * @param configuration describes all device configuration information
 * @param mainView      ViewGroup resources
 * @param textView      alert message to be viewed message to be displayedView
 */
@SuppressLint("NewApi")
private static void setIcon(Activity context, Configuration configuration, ViewGroup mainView,
        TextView textView) {

    ImageView imageView = (ImageView) mainView.findViewById(R.id.alert_view_icon);

    // Reset the current icon
    if (imageView != null) {
        mainView.removeView(imageView);
    }

    // On the textview as well
    textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    textView.setCompoundDrawablePadding(0);

    if (configuration.getIconResId() != -1) {

        imageView = new ImageView(context);
        imageView.setId(R.id.alert_view_icon);

        imageView.setImageResource(configuration.getIconResId());
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        imageView.setLayoutParams(layoutParams);

        switch (configuration.getIconPosition()) {
        case LEFT_TEXT:
            textView.setCompoundDrawablesWithIntrinsicBounds(configuration.getIconResId(), 0, 0, 0);
            textView.setCompoundDrawablePadding(10);
            break;

        case RIGHT_TEXT:
            textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, configuration.getIconResId(), 0);
            textView.setCompoundDrawablePadding(10);
            break;

        case LEFT:
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START);
            }

            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            layoutParams.setMargins(25, 0, 0, 0);
            mainView.addView(imageView);

            // We redefine the layout params otherwise the image is not well aligned
            textView.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
            break;
        case RIGHT:
        default:
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                layoutParams.addRule(RelativeLayout.ALIGN_PARENT_END);
            }

            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            layoutParams.setMargins(0, 0, 25, 0);
            mainView.addView(imageView);

            // We redefine the layout params otherwise the image is not well aligned
            textView.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
            break;
        }
    }
}

From source file:com.just.agentweb.AgentWebUtils.java

static final void clearWebView(WebView m) {

    if (m == null) {
        return;/*from  w w  w  . j av a 2 s  .  c  o  m*/
    }
    if (Looper.myLooper() != Looper.getMainLooper()) {
        return;
    }
    m.loadUrl("about:blank");
    m.stopLoading();
    if (m.getHandler() != null) {
        m.getHandler().removeCallbacksAndMessages(null);
    }
    m.removeAllViews();
    ViewGroup mViewGroup = null;
    if ((mViewGroup = ((ViewGroup) m.getParent())) != null) {
        mViewGroup.removeView(m);
    }
    m.setWebChromeClient(null);
    m.setWebViewClient(null);
    m.setTag(null);
    m.clearHistory();
    m.destroy();
    m = null;

}

From source file:com.shopify.buy.ui.ViewPagerAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object view) {
    container.removeView((View) view);
}

From source file:android.support.test.testapp.SimplePagerAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView((View) object);
}

From source file:com.flan.stock.adapter.NewsTouTiaoViewPagerAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView(viewList.get(position));
}

From source file:klawisch.jimdo.statistics.statisticsdemo.PagerAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView((View) container);
}

From source file:emu.project64.AboutPagerAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView((View) object);
    mLists.remove(position);/*from  w  w w .  j a v a  2  s. c  o  m*/
}

From source file:com.yanzhenjie.album.adapter.BasicPreviewAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView(((View) object));
}