Java Code Examples for android.view.ViewGroup.removeView()

The following are Jave code examples for showing how to use removeView() of the android.view.ViewGroup class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: PagerSlidingTabStrip   File: FourFragment.java   View Source Code Vote up 6 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (view == null) {
        view = inflater.inflate(R.layout.fragment_view, container, false);
        //在这里做一些初始化处理
        TextView textView = (TextView) view.findViewById(R.id.tv_content);
        textView.setText("第四个");
    } else {
        ViewGroup viewGroup = (ViewGroup) view.getParent();
        if (viewGroup != null)
            viewGroup.removeView(view);
    }
    return view;

}
 
Example 2
Project: CXJPadProject   File: AddOrderServiceFragment.java   View Source Code Vote up 6 votes
@Override  //Outsourcing
protected View initRootView(LayoutInflater inflater) {
    if (view == null) {
        view = View.inflate(getActivity(), R.layout.fragment_add_order_service, null);
    }
    ButterKnife.bind(this, view);
    ViewGroup myparent = (ViewGroup) view.getParent();
    //获取args传递的参数
    if (getArguments() != null) {
        argsModel = (OrderModel) getArguments().getSerializable("args");
        Log.d(TAG, "initRootView: " + argsModel.assessScore);
    }
    if (myparent != null) {
        myparent.removeView(view);
    }
    return view;
}
 
Example 3
Project: SmingZZick_App   File: StickerApplyAdapter.java   View Source Code Vote up 6 votes
public void deleteSticker(long attachId) {
    if (stickers == null) {
        return;
    }

    Stickerable stickerableToDelete = null;
    for (Stickerable stickerable : stickers) {
        if (attachId == stickerable.getAttachId()) {
            stickerableToDelete = stickerable;
            break;
        }
    }

    if (stickerableToDelete == null) {
        return;
    }

    stickers.remove(stickerableToDelete);
    ViewGroup parent = (ViewGroup) ((View) stickerableToDelete).getParent();
    parent.removeView((View) stickerableToDelete);

    notifyDataSetChanged();
    if (onStickerApplyEventListener != null) {
        onStickerApplyEventListener.onStickerRemove(stickerableToDelete);
    }
}
 
Example 4
Project: open-rmbt   File: RMBTResultPagerAdapter.java   View Source Code Vote up 5 votes
/**
* 
*/
  @Override
  public void destroyItem(final ViewGroup vg, final int i, final Object obj)
  {
      final View view = (View) obj;
      vg.removeView(view);
  }
 
Example 5
Project: QiangHongBao   File: BottomBarBadge.java   View Source Code Vote up 5 votes
void removeFromTab(BottomBarTab tab) {
    FrameLayout badgeAndTabContainer = (FrameLayout) getParent();
    ViewGroup originalTabContainer = (ViewGroup) badgeAndTabContainer.getParent();

    badgeAndTabContainer.removeView(tab);
    originalTabContainer.removeView(badgeAndTabContainer);
    originalTabContainer.addView(tab, tab.getIndexInTabContainer());
}
 
Example 6
Project: android_ui   File: RefreshListFragment.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("ConstantConditions")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final ViewGroup view = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);
	view.removeView(view.findViewById(android.R.id.list));
	view.addView(mListView = (ListViewWidget) inflater.inflate(R.layout.list_view_swipe_to_refresh, container, false));
	return view;
}
 
Example 7
Project: renderscript_examples   File: MainActivity.java   View Source Code Vote up 5 votes
void replaceView(View originalView, View newView) {
    originalView.setTag(newView);

    newView.setLayoutParams(new FrameLayout.LayoutParams(originalView.getLayoutParams()));

    ViewGroup parent = (ViewGroup) originalView.getParent();
    int index = parent.indexOfChild(originalView);
    parent.removeView(originalView);

    parent.addView(newView, index);
}
 
Example 8
Project: AndroidBasicLibs   File: ViewUtils.java   View Source Code Vote up 5 votes
public static void removeSelfFromParent(View view) {
    if (view != null) {
        ViewParent parent = view.getParent();
        if (parent != null && parent instanceof ViewGroup) {
            ViewGroup group = (ViewGroup) parent;
            group.removeView(view);
        }
    }
}
 
Example 9
Project: LoRaWAN-Smart-Parking   File: CordovaActivity.java   View Source Code Vote up 5 votes
@SuppressWarnings("deprecation")
protected void createViews() {
    // This builds the view.  We could probably get away with NOT having a LinearLayout, but I like having a bucket!

    LOG.d(TAG, "CordovaActivity.createViews()");

    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();

    root = new LinearLayoutSoftKeyboardDetect(this, width, height);
    root.setOrientation(LinearLayout.VERTICAL);
    root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));

    appView.setId(100);
    appView.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT,
            1.0F));

    // need to remove appView from any existing parent before invoking root.addView(appView)
    ViewParent parent = appView.getParent();
    if ((parent != null) && (parent != root)) {
        LOG.d(TAG, "removing appView from existing parent");
        ViewGroup parentGroup = (ViewGroup) parent;
        parentGroup.removeView(appView);
    }
    root.addView((View) appView);
    setContentView(root);

    int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK);
    root.setBackgroundColor(backgroundColor);
}
 
Example 10
Project: Review-   File: SettingFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (mRootView == null) {
        mRootView = inflater.inflate(R.layout.fragment_setting, container, false);
        creatViews();
    }
    //缓存的mRootView需要判断是否已经被加过parent, 如果有parent需要从parent删除,要不然会发生这个mRootView已经有parent的错误。
    ViewGroup parent = (ViewGroup) mRootView.getParent();
    if (parent != null) {
        parent.removeView(mRootView);
    }
    return mRootView;

}
 
Example 11
Project: react-native-tabbed-view-pager-android   File: ReactViewPager.java   View Source Code Vote up 4 votes
@Override public void destroyItem(ViewGroup container, int position, Object object) {
  container.removeView((View) object);
}
 
Example 12
Project: MyAnimeViewer   File: FabFilterFragment.java   View Source Code Vote up 4 votes
@Override
public void destroyItem(ViewGroup collection, int position, Object view) {
    collection.removeView((View) view);
}
 
Example 13
Project: backstack   File: LinearBackStack.java   View Source Code Vote up 4 votes
private void removeView(BackStackNode backStackNode, ViewGroup viewGroup){
    if (!backStackNode.shouldRetain){
        ViewGroup parent = (ViewGroup) viewGroup.getParent();
        parent.removeView(viewGroup);
    }
}
 
Example 14
Project: RetroMusicPlayer   File: NowPlayingScreenPreferenceDialog.java   View Source Code Vote up 4 votes
@Override
public void destroyItem(@NonNull ViewGroup collection,
                        int position,
                        @NonNull Object view) {
    collection.removeView((View) view);
}
 
Example 15
Project: ZoomPreviewPicture   File: MyPagerAdaper.java   View Source Code Vote up 4 votes
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView((View) object);
}
 
Example 16
Project: GitHub   File: CardPagerAdapter.java   View Source Code Vote up 4 votes
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView((View) object);
    mViews.set(position, null);
}
 
Example 17
Project: GitHub   File: BaseLoopPagerAdapter.java   View Source Code Vote up 4 votes
@Override
public final void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView((View) object);
}
 
Example 18
Project: BloomReader   File: ReaderActivity.java   View Source Code Vote up 4 votes
@Override
public void destroyItem(ViewGroup collection, int position, Object view) {
    Log.d("Reader", "destroyItem " + position);
    collection.removeView((View) view);
    mActiveViews.remove(position);
}
 
Example 19
Project: PeSanKita-android   File: EmojiDrawer.java   View Source Code Vote up 4 votes
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
  container.removeView((View)object);
}
 
Example 20
Project: MyDemo   File: MoviePhotoPagerAdapter.java   View Source Code Vote up 4 votes
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    View view = (View) object;
    container.removeView(view);
}