onCreateView is being called again upon returning and your fragment is being recreated. One solution is to save your fragment state in onSaveInstanceState and reload it in onCreateView:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
..
if (savedInstanceState != null) {
// reload state
}
..
}
public void onSaveInstanceState (Bundle outState) {
// save dynamic state in outState
}
EDIT:
I've found this to work if you would like to keep the actual view:
private View mLayout;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (mLayout == null) {
// this is the first time onCreateView has been called
mLayout = inflater.inflate(..);
} else {
// remove previous parent
ViewParent parent = mLayout.getParent();
if (parent != null)
((ViewGroup) parent).removeView(mLayout);
}
return mLayout;
}