Get fragment's container view id

You can access the container's id by calling

((ViewGroup)getView().getParent()).getId();

I don't know if I exactly understand your question, but you get the Container in onCreateView. I suppose you could stash it in a local variable.

public View onCreateView(LayoutInflater inflater, 
  ViewGroup container,
  Bundle savedInstanceState) {
  mContainer = container;
  ...
}

I think there's a more standard way of accessing the view rather than using

((ViewGroup) getView().getParent()).getId()

I will assume that you're working with a MainActivity that presents a list fragment, which can then present another list fragment upon clicking an item, and so on. I'm assuming that you've chosen to replace the main view of MainActivity with the contents of the list fragments you present.

Because each list fragment is being hosted in the MainActivity, you can always access the view of the MainActivity.

// Inside of onListItemClick...
FragmentManager fm = getFragmentManager();
Fragment fragment = new MyOtherListFragment();

FrameLayout contentView = (FrameLayout) getActivity().findViewById(R.id.content_view);

fm.beginTransaction()
        .replace(contentView.getId(), fragment)
        .addToBackStack(null)
        .commit();

The above example assumes you have an XML layout resource that you set in the MainActivity, call the XML resource R.layout.activity_main, where there is a FrameLayout with the id R.id.content_view. This is the approach I took. The example I present here is a simpler version from the one that I actually wrote in my app.

Incidentally, my version of IntelliJ (version 1.0.1) warns me that

((ViewGroup) getView().getParent)

may throw a NullPointerException.