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.example.ray.firstapp.bottombar.BottomBar.java

/**
 * Bind the BottomBar to your Activity, and inflate your layout here.
 * <p/>// w  ww .jav  a  2  s  .co m
 * Remember to also call {@link #onRestoreInstanceState(Bundle)} inside
 * of your {@link Activity#onSaveInstanceState(Bundle)} to restore the state.
 *
 * @param activity           an Activity to attach to.
 * @param savedInstanceState a Bundle for restoring the state on configuration change.
 * @return a BottomBar at the bottom of the screen.
 */
public static BottomBar attach(Activity activity, Bundle savedInstanceState) {
    BottomBar bottomBar = new BottomBar(activity);
    bottomBar.onRestoreInstanceState(savedInstanceState);

    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    View oldLayout = contentView.getChildAt(0);
    contentView.removeView(oldLayout);

    bottomBar.setPendingUserContentView(oldLayout);
    contentView.addView(bottomBar, 0);

    return bottomBar;
}

From source file:com.mk4droid.IMC_Activities.Fragment_List.java

/** on create this fragment view */
@Override//from ww w  .  ja  v  a2  s.  c om
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    FActivity_TabHost.IndexGroup = 1;

    if (vFragment_List != null) {
        ViewGroup parent = (ViewGroup) vFragment_List.getParent();
        if (parent != null)
            parent.removeView(vFragment_List);
    }

    try {
        if (vFragment_List == null)
            vFragment_List = inflater.inflate(R.layout.fragment_list, container, false);
    } catch (InflateException e) {
        /* map is already there, just return view as it is */
    }

    mFragment_List = this;
    ctx = mFragment_List.getActivity();

    lvIssues = (ListView) vFragment_List.findViewById(R.id.lvIssues);

    //--------------- Receiver for Data change ------------
    HandlersAndReceivers();

    resources = setResources();
    handlerBroadcastListRefresh.sendMessage(new Message());

    //---------- Buttons -----------
    ll_listissues_MyIssues = (LinearLayout) vFragment_List.findViewById(R.id.ll_listissues_MyIssues);

    btListMyIss = (Button) vFragment_List.findViewById(R.id.bt_listissues_MyIssues);
    btListAllIss = (Button) vFragment_List.findViewById(R.id.bt_listissues_AllIssues);

    // onclick listeners
    btListMyIss.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            SetComplementaryButtons();
        }
    });

    btListAllIss.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            SetComplementaryButtons();
        }
    });

    //-----------------------
    if (Fragment_Issue_Details.mfrag_issue_details != null)
        if (Fragment_Issue_Details.mfrag_issue_details.isVisible())
            getChildFragmentManager().beginTransaction().hide(mFragment_List).commit();

    return vFragment_List;
}

From source file:com.google.android.apps.santatracker.dasherdancer.CharacterAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    if (position < mCharacters.length) {
        View view = mViews.get(position);
        if ((view == null) && (object != null)) {
            try {
                view = (ImageView) object;
            } catch (ClassCastException e) {
                Log.e(LOG_TAG, "Wrong type of object supplied to destroyItem.");
            }/* w w w. j  a  v  a  2  s. co m*/
        }

        if (view != null) {
            container.removeView(view);
        }

        mViews.remove(position);
    }
}

From source file:de.k3b.android.androFotoFinder.imagedetail.ImagePagerAdapterFromCursor.java

/**
 * Implementation for PagerAdapter:/*  w  w  w .  ja  v a 2s  .  c om*/
 * Remove a page for the given position.  The adapter is responsible
 * for removing the view from its container, although it only must ensure
 * this is done by the time it returns from {@link #finishUpdate(ViewGroup)}.
 *
 * @param container The containing View from which the page will be removed.
 * @param position The page position to be removed.
 * @param object The same object that was returned by
 * {@link #instantiateItem(View, int)}.
 */
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    if (Global.debugEnabledViewItem)
        Log.i(Global.LOG_CONTEXT, debugPrefix + "destroyItem(#" + position + ") " + object);
    container.removeView((View) object);
    GarbageCollector.freeMemory((View) object); // to reduce memory leaks
}

From source file:org.zywx.wbpalmstar.plugin.uexiconlist.EUExIconList.java

/**
 * @param jsonData/*from   w ww  .  jav a2s. co  m*/
 * @return
 */
private String openIconList(final String jsonData) {
    String errorMsg = "";
    if (!isIconListOpened) {
        ((Activity) mContext).runOnUiThread(new Runnable() {

            @Override
            public void run() {
                Rect outRect = new Rect();
                ((Activity) mContext).getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
                try {
                    JSONObject json = new JSONObject();
                    json.put(JK_WIDGET_PATH, mWWidgetData.getWidgetPath());
                    json.put(JK_WIDGET_TYPE, mWWidgetData.m_wgtType);
                    Intent intent = new Intent(mContext, IconListActivity.class);
                    intent.putExtra(WIDGET_INFO, json.toString());
                    intent.putExtra(ITEM_INFO, jsonData);
                    if (mgr == null) {
                        mgr = new LocalActivityManager((Activity) mContext, false);
                        mgr.dispatchCreate(null);
                    }
                    Window window = mgr.startActivity(IconListActivity.TAG, intent);
                    View marketDecorView = window.getDecorView();
                    if (IconListOption.isFollowWebRoll()) {
                        AbsoluteLayout.LayoutParams lp = new AbsoluteLayout.LayoutParams(
                                (int) UIConfig.getWidth(), (int) UIConfig.getHight(), (int) UIConfig.getX(),
                                (int) UIConfig.getY());
                        ViewGroup viewGroup = (ViewGroup) marketDecorView.getParent();
                        if (viewGroup != null) {
                            viewGroup.removeView(marketDecorView);
                        }
                        addViewToWebView(marketDecorView, lp, IconListActivity.TAG);
                    } else {
                        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                                (int) UIConfig.getWidth(), (int) UIConfig.getHight());
                        lp.leftMargin = (int) UIConfig.getX();
                        lp.topMargin = (int) UIConfig.getY();
                        addViewToCurrentWindow(marketDecorView, lp);
                    }
                    isIconListOpened = true;
                    mIconListActivity = (IconListActivity) mgr.getActivity(IconListActivity.TAG);
                    mIconListActivity.initView(EUExIconList.this);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }// end run()
        });
    } // end if
    else {
        errorMsg = ERROR_MSG_ALREADY_OPEN;
    }
    return errorMsg;
}

From source file:com.example.ray.firstapp.bottombar.BottomBar.java

/**
 * Bind the BottomBar to the specified View's parent, and inflate
 * your layout there. Useful when the BottomBar overlaps some content
 * that shouldn't be overlapped.// w  w w.  ja v  a  2s .co m
 * <p/>
 * Remember to also call {@link #onRestoreInstanceState(Bundle)} inside
 * of your {@link Activity#onSaveInstanceState(Bundle)} to restore the state.
 *
 * @param view               a View, which parent we're going to attach to.
 * @param savedInstanceState a Bundle for restoring the state on configuration change.
 * @return a BottomBar at the bottom of the screen.
 */
public static BottomBar attach(View view, Bundle savedInstanceState) {
    BottomBar bottomBar = new BottomBar(view.getContext());
    bottomBar.onRestoreInstanceState(savedInstanceState);

    ViewGroup contentView = (ViewGroup) view.getParent();

    if (contentView != null) {
        View oldLayout = contentView.getChildAt(0);
        contentView.removeView(oldLayout);

        bottomBar.setPendingUserContentView(oldLayout);
        contentView.addView(bottomBar, 0);
    } else {
        bottomBar.setPendingUserContentView(view);
    }

    return bottomBar;
}

From source file:com.dspot.declex.actions.AlertDialogActionHolder.java

/**
 * @param PositiveButtonPressed <i><b>(default)</b></i> This Action Selector will be executed when the positive button is pressed in
 * the AlertDialog/*from w w  w . j a  v  a  2 s  . co m*/
 * @param NegativeButtonPressed This Action Selector will be executed when the negative button is pressed in
 * the AlertDialog
 * @param NeutralButtonPressed This Action Selector will be executed when the neutral button is pressed in
 * the AlertDialog 
 * @param Canceled This Action Selector will be executed when the AlertDialog is canceled
 * @param Canceled This Action Selector will be executed when the AlertDialog is dismissed  
 */
void build(final DialogClickRunnable PositiveButtonPressed, final DialogClickRunnable NegativeButtonPressed,
        final DialogClickRunnable NeutralButtonPressed, final DialogClickRunnable ItemSelected,
        final DialogMultiChoiceClickRunnable MultiChoiceSelected, final Runnable Canceled,
        final Runnable Dismissed) {

    if (negativeButtonText != null) {
        builder.setNegativeButton(negativeButtonText, NegativeButtonPressed);
    } else if (negativeButtonRes != 0) {
        builder.setNegativeButton(negativeButtonRes, NegativeButtonPressed);
    }

    if (positiveButtonText != null) {
        builder.setPositiveButton(positiveButtonText, PositiveButtonPressed);
    } else if (positiveButtonRes != 0) {
        builder.setPositiveButton(positiveButtonRes, PositiveButtonPressed);
    }

    if (neutralButtonText != null) {
        builder.setNeutralButton(neutralButtonText, NeutralButtonPressed);
    } else if (neutralButtonRes != 0) {
        builder.setNeutralButton(neutralButtonRes, NeutralButtonPressed);
    }

    if (items != null) {
        builder.setItems(items, ItemSelected);
    } else if (itemsRes != 0) {
        builder.setItems(itemsRes, ItemSelected);
    }

    if (multiChoiceItems != null) {
        builder.setMultiChoiceItems(multiChoiceItems, checkedItems, MultiChoiceSelected);
    } else if (multiChoiceRes != 0) {
        builder.setMultiChoiceItems(multiChoiceRes, checkedItems, MultiChoiceSelected);
    }

    dialog = builder.create();

    if (Canceled != null) {
        dialog.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface arg0) {
                Canceled.run();
            }
        });
    }

    if (Dismissed != null || customView != null) {
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface arg0) {
                if (customView != null) {
                    ViewGroup parent = (ViewGroup) customView.getParent();
                    parent.removeView(customView);
                }
                if (Dismissed != null)
                    Dismissed.run();
            }
        });
    }
}

From source file:com.devspark.progressfragment.ProgressFragment.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.
 *
 * @param view The desired content to display. Value can't be null.
 * @see #setContentView(int)/*  w  w  w .j  a  va  2s. co  m*/
 * @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;
        if (mContentView == null) {
            contentContainer.addView(view);
        } else {
            int index = contentContainer.indexOfChild(mContentView);
            // replace content view
            contentContainer.removeView(mContentView);
            contentContainer.addView(view, index);
        }
        mContentView = view;
    } else {
        throw new IllegalStateException("Can't be used with a custom content view");
    }
}

From source file:it.geosolutions.geocollect.android.core.mission.PendingMissionDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView(): container = " + container + "savedInstanceState = " + savedInstanceState);

    if (mScrollView == null) {
        // normally inflate the view hierarchy
        mScrollView = (ScrollView) inflater.inflate(R.layout.preview_page_fragment, container, false);
        mFormView = (LinearLayout) mScrollView.findViewById(R.id.previewcontent);
        mProgressView = (ProgressBar) mScrollView.findViewById(R.id.loading);
    } else {//from  ww  w.java2s  .c  om
        // mScrollView is still attached to the previous view hierarchy
        // we need to remove it and re-attach it to the current one
        ViewGroup parent = (ViewGroup) mScrollView.getParent();
        parent.removeView(mScrollView);
    }
    //TODO it should be false because orientation change can 
    // have different layout (for map view )
    //setRetainInstance(true);
    return mScrollView;

}

From source file:com.yahala.ui.GroupCreateFinalActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentView == null) {
        fragmentView = inflater.inflate(R.layout.group_create_final_layout, container, false);

        final ImageButton button2 = (ImageButton) fragmentView.findViewById(R.id.settings_change_avatar_button);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override//  w w  w .j ava2  s .c o m
            public void onClick(View view) {

                AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);

                CharSequence[] items;

                if (avatar != null) {
                    items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera),
                            LocaleController.getString("FromGalley", R.string.FromGalley),
                            LocaleController.getString("DeletePhoto", R.string.DeletePhoto) };
                } else {
                    items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera),
                            LocaleController.getString("FromGalley", R.string.FromGalley) };
                }

                builder.setItems(items, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        if (i == 0) {
                            //     avatarUpdater.openCamera();
                        } else if (i == 1) {
                            //    avatarUpdater.openGallery();
                        } else if (i == 2) {
                            avatar = null;
                            uploadedAvatar = null;
                            //   avatarImage.setImage(avatar, "50_50", R.drawable.group_blue);
                        }
                    }
                });
                builder.show().setCanceledOnTouchOutside(true);
            }
        });

        avatarImage = (PictureImplCircleImageView) fragmentView.findViewById(R.id.settings_avatar_image);

        nameTextView = (EditText) fragmentView.findViewById(R.id.bubble_input_text);
        nameTextView.setHint(
                LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder));
        listView = (PinnedHeaderListView) fragmentView.findViewById(R.id.listView);
        listView.setAdapter(new ListAdapter(parentActivity));
    } else {
        ViewGroup parent = (ViewGroup) fragmentView.getParent();
        if (parent != null) {
            parent.removeView(fragmentView);
        }
    }
    return fragmentView;
}