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.concentricsky.android.khanacademy.app.SignInActivity.java

/**
 * Show a loading indicator.//from   w  w  w . j a  v a2  s. c  o  m
 */
protected void showSpinner() {
    if (spinnerView == null) {
        spinnerView = getLayoutInflater().inflate(R.layout.spinner, null, false);
    }
    handler.post(new Runnable() {
        public void run() {
            ViewGroup parent = (ViewGroup) spinnerView.getParent();
            if (parent != null)
                parent.removeView(spinnerView);
            ((FrameLayout) findViewById(R.id.popover_view)).addView(spinnerView);
        }
    });
}

From source file:com.forrestguice.suntimeswidget.LocationDialog.java

public AlertDialog toAlertDialog() {
    ViewGroup dialogFrame = (ViewGroup) this.getWindow().getDecorView();
    View dialogContent = dialogFrame.getChildAt(0);
    dialogFrame.removeView(dialogContent);

    AlertDialog.Builder builder = new AlertDialog.Builder(myParent);
    builder.setView(dialogContent);//from   ww w .j  a v a  2s  .c o m
    AlertDialog dialog = builder.create();

    dialog.setButton(AlertDialog.BUTTON_NEGATIVE, myParent.getString(R.string.location_dialog_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    getFixHelper.cancelGetFix();
                    dialog.dismiss();

                    if (onCanceled != null) {
                        onCanceled.onClick(dialog, which);
                    }
                }
            });

    dialog.setButton(AlertDialog.BUTTON_POSITIVE, myParent.getString(R.string.location_dialog_ok),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    getFixHelper.cancelGetFix();
                    saveSettings(myParent);
                    dialog.dismiss();

                    if (onAccepted != null) {
                        onAccepted.onClick(dialog, which);
                    }
                }
            });

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            loadSettings(myParent);
        }
    });

    dialog.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialogInterface) {
        }
    });

    return dialog;
}

From source file:com.grottworkshop.gwsmaterialcalendarview.MonthPagerAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    MonthView monthView = (MonthView) object;
    currentViews.remove(monthView);// ww  w .j  ava2s  . c  o  m
    container.removeView(monthView);
}

From source file:com.concentricsky.android.khanacademy.app.SignInActivity.java

/**
 * Hide any loading indicator.//from w ww  .  jav a2  s.  c o m
 */
protected void hideSpinner() {
    if (spinnerView != null) {
        handler.post(new Runnable() {
            public void run() {
                ViewGroup parent = (ViewGroup) spinnerView.getParent();
                if (parent != null)
                    parent.removeView(spinnerView);
            }
        });
    }
}

From source file:com.ashlikun.badgeview.BadgeView.java

public void setTargetView(View target) {
    if (getParent() != null) {
        ((ViewGroup) getParent()).removeView(this);
    }//  w  w w . j  a v a2 s . c o m

    if (target == null) {
        return;
    }

    if (target.getParent() instanceof FrameLayout) {
        ((FrameLayout) target.getParent()).addView(this);

    } else if (target.getParent() instanceof ViewGroup) {
        // use a new Framelayout container for adding badge
        ViewGroup parentContainer = (ViewGroup) target.getParent();
        int groupIndex = parentContainer.indexOfChild(target);
        parentContainer.removeView(target);

        FrameLayout badgeContainer = new FrameLayout(getContext());
        ViewGroup.LayoutParams parentLayoutParams = target.getLayoutParams();

        badgeContainer.setLayoutParams(parentLayoutParams);
        target.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        parentContainer.addView(badgeContainer, groupIndex, parentLayoutParams);
        badgeContainer.addView(target);

        badgeContainer.addView(this);
    } else if (target.getParent() == null) {
        Log.e(getClass().getSimpleName(), "ParentView is needed");
    }

}

From source file:ir.besteveryeverapp.ui.ActionBar.BaseFragment.java

protected void clearViews() {
    if (fragmentView != null) {
        ViewGroup parent = (ViewGroup) fragmentView.getParent();
        if (parent != null) {
            try {
                parent.removeView(fragmentView);
            } catch (Exception e) {
                FileLog.e("tmessages", e);
            }//  w w w . j av a2s.c  o m
        }
        fragmentView = null;
    }
    if (actionBar != null) {
        ViewGroup parent = (ViewGroup) actionBar.getParent();
        if (parent != null) {
            try {
                parent.removeView(actionBar);
            } catch (Exception e) {
                FileLog.e("tmessages", e);
            }
        }
        actionBar = null;
    }
    parentLayout = null;
}

From source file:com.example.android.animationsdemo.BoardFragment.java

public void addItem(View view) {

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View newCard = inflater.inflate(R.layout.new_card_layout, null, false);
    newCard.setTag("newCard");
    ViewGroup parentCol = (ViewGroup) view.getParent();
    ViewGroup svCol = (ViewGroup) parentCol.getChildAt(parentCol.getChildCount() - 1);
    ViewGroup containerCol = (ViewGroup) svCol.getChildAt(0);
    View check = containerCol.findViewWithTag("newCard");
    if (check == null)
        containerCol.addView(newCard, 0);
    else//from ww w.j a va  2s.com
        containerCol.removeView(check);
    ImageView save = (ImageView) newCard.findViewById(R.id.saveNewCard);
    final EditText title = (EditText) newCard.findViewById(R.id.newCardTitle);
    save.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view1) {
            if (isEmpty(title))
                Toast.makeText(context, "Please enter a title", Toast.LENGTH_SHORT).show();
            else {
                query = "";
                pager.getAdapter().notifyDataSetChanged();
                InputMethodManager imm = (InputMethodManager) context
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(title.getWindowToken(), 0);
            } //
        }
    });
}

From source file:com.lee.sdk.widget.viewpager.PagerAdapterImpl.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    if (DEBUG) {//w  ww .j  a va  2s.co  m
        Log.i(TAG, "destroyItem    position = " + position + "    recycle a view~~~~~~~");
    }

    View view = (View) object;

    // 
    if (view instanceof OnRecycleListener) {
        ((OnRecycleListener) view).recycle();
    }

    container.removeView(view);
    mViewPool.recycle(view);
    mViewList.remove(position);
}

From source file:com.phonemetra.turbo.keyboard.emoji.EmojiPalettesAdapter.java

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

    final EmojiPageKeyboardView keyboardView = mActiveKeyboardViews.get(position);
    if (keyboardView != null) {
        keyboardView.deallocateMemory();
        mActiveKeyboardViews.remove(position);
    }/*from  ww  w.  j a v  a2  s  . co m*/
    if (object instanceof View) {
        container.removeView((View) object);
    }
}

From source file:com.mirasense.scanditsdk.plugin.SubViewPickerController.java

private void internalRemoveSubviewPicker() {
    if (Looper.myLooper() == null || Looper.myLooper().getThread() != Thread.currentThread()) {
        throw new RuntimeException("must be called on main thread");
    }/*from   w w w .  j  a  v  a  2s  .co  m*/
    if (mPickerStateMachine == null) {
        return;
    }
    mPickerStateMachine.setState(PickerStateMachine.STOPPED);
    ViewGroup viewGroup = getPickerParent();
    if (viewGroup != null) {
        viewGroup.removeView(mLayout);
    }
    mLayout = null;
    mPickerStateMachine = null;
}