I'm trying to remove an inflated view. This is how I inflate the view:
ViewGroup vg = (ViewGroup)findViewById(android.R.id.content).getRootView();
mOverflowMenuView = View.inflate(this, R.layout.overflow_menu, vg);
And this is how I try to remove it from onBackPressed
ViewGroup vg = (ViewGroup)(mOverflowMenuView.getParent());
vg.removeView(mOverflowMenuView);
But I get a class cast exception:
03-11 22:47:31.848: E/AndroidRuntime(26357): java.lang.ClassCastException: android.view.ViewRootImpl cannot be cast to android.view.ViewGroup
Any ideas?