How to fix 'android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5035)' error in android

I have layout with child (NOT as root) element RelativeLayout and then i create ViewPager and insert it as child of my Relative layout, so it's like

+Relative Layout (root)

|

+-- Relative Layout (child)

|

+-- -- ViewPager

For now moment - all ok.

But then i try add some view item to ViewPager with own layout then i got error

10-12 15:32:46.777: E/AndroidRuntime(6031): FATAL EXCEPTION: main
10-12 15:32:46.777: E/AndroidRuntime(6031): java.lang.StackOverflowError
10-12 15:32:46.777: E/AndroidRuntime(6031):     at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5035)

How do that ViewPager will me as Child of RelativeLayout with havin own Child Views?


Problem solved!

It's happened because I call LayoutInflater.inflate([subViewOfViewPager], [ParentOfViewPager])

it should be:

LayoutInflater.inflate([subViewOfViewPager], [ParentOfViewPager], false))

More words:

It's happened because when called inflate with second parameter, view inserting as subchild of given ViewGroup, and then I try add this View to ViewPager. View can have only one Parent ViewGroup element. The third parameter sets attachToRoot to false to avoid this.


Simplified version of answer

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.cab_listing, container,false);
    return view;
}