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

后端 未结 2 1441
再見小時候
再見小時候 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: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.)

提交回复
热议问题