Error inflating class fragment error when loading custom fragment with fragment (valid)

Most of the ways that this error occurs online are
1. Check fragment package name, support.v4 is not the same as normal
Check your activity. If you are using a v4 fragment, you must inherit FragmentActivity (v4), or you can use CompatActivity(V7).
3. Static load fragment must give id
There may also be some other logic errors, such as whether the oncreateview fragment has loaded the correct layout, whether the parse is correct, whether the return is correct, etc.

If the above operation can not solve the error, then there is only one way, dynamic loading, it seems that the V4 package fragment does not support static loading, the specific reason has not been found, try dynamic loading can be used normally
V4 package dynamic loading: getSupportFragmentManager (). The beginTransaction (). The replace (layoutId, fragments, the tag). The commit ();
Non-v4 packages can load statically and dynamically.

Read More: