Skip to content

Instantly share code, notes, and snippets.

@rafacouto
Last active December 31, 2015 22:59
Show Gist options
  • Save rafacouto/8056818 to your computer and use it in GitHub Desktop.
Save rafacouto/8056818 to your computer and use it in GitHub Desktop.
See "Error inflating class fragment" answer: http://stackoverflow.com/a/20685549/470091
package net.treboada.mytests.fragments;
import android.app.Activity;
import android.os.Bundle;
import android.util.AttributeSet;
public class XmlFragment extends android.support.v4.app.Fragment {
@Override
public void onInflate(Activity activity, AttributeSet attrs,
Bundle savedInstanceState) {
android.support.v4.app.FragmentManager fm = getFragmentManager();
if (fm != null) {
fm.beginTransaction().remove(this).commit();
}
super.onInflate(activity, attrs, savedInstanceState);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment