How to use chart inside fragment in Android using Achartengine library?

后端 未结 2 1447
再見小時候
再見小時候 2021-01-03 14:17

I have an activity 3ChartPerTabActivity where i have 3 tabs fragment with Viepager.Each fragment view has just different color.So far is working.

My problem occurs w

相关标签:
2条回答
  • 2021-01-03 14:47

    In my case, I use the SherlockFragment and had the same problem.

    After replacing the LinearLayout to ViewGroup, it shows the graph.

    ViewGroup chartContainer = (ViewGroup)view.findViewById(R.id.chart_container);
    

    I hope it works for you and others who have the same problem.

    0 讨论(0)
  • 2021-01-03 14:50

    getView doesn't work until AFTER onCreateView completes: http://developer.android.com/reference/android/app/Fragment.html#getView()

    Use the View that you inflate in onCreateView as a starting point to "find" your other views while you're still in onCreateView, instead of getView().

    For example:

    View view = (LinearLayout) inflater.inflate(R.layout.tab_frag1_layout,
                    container, false);
    LinearLayout chartContainer = (LinearLayout) view.findViewById(
            R.id.chart_container);
    ...
    return view;
    

    (Assuming "tab_frag1_layout" has the "chart_container" layout inside it.)

    0 讨论(0)
提交回复
热议问题