Android: Error creating SupportChartFragment within another fragment (1)


#1

Hello,

I’m using a ViewPager to contain fragments, and would like to embed a Shinobi SupportChartFragment within each fragment. However, I get an exception while inflating the view: 

android.view.InflateException: Binary XML file line #10: Error inflating class fragment

It’s not obvious from the callstack what’s going on, but if I break on exceptions, this is the exception which is causing it (fragment.java):

    public void setRetainInstance(boolean retain) {
        if (retain && mParentFragment != null) {
            throw new IllegalStateException(
                    "Can't retain fragements that are nested in other fragments");               }
       mRetainInstance = retain;
     }

I understand that using a ChartView might be another way of doing it, but I’m reluctant to start out integrating a componnt which requires me to use deprecated code. If in the future Google decided to retire those calls, i’d be stuck.

Is there any other way of making it work?

Thanks,

Sacha


#2

[Duplicate of https://www.shinobicontrols.com/forum/shinobicontrols/2016/2/android-error-creating-supportchartfragment-within-another-fragment]


#3

Hi - the link you posted takes me to my original question. Is this what you meant?


#4

Hi. 

Just to clarify - my colleague Patrick did mean to do this. Your question seemed to be posted twice, this post being the duplicate (notice the -(1) suffix in the url) . Patrick has provided a response to the first copy of this thread, the link to which he provided above. 

I hope that this clears things up.

Thanks,

Kai.