achartengine:如何在Tabs中将图表添加到片段

时间:2013-01-09 20:28:46

标签: android layout charts fragment achartengine

我想在标签中显示下面的Button和PieChart。 那是我使用过的代码:https://github.com/JakeWharton/ActionBarSherlock/blob/master/samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentTabs.java 而不是CountingFragment等我实现了自己的。

我不知道该怎么做

我的xml: fragment_graph_categories.xml

  <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/fragment_graph_categories"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <Button
            android:id="@+id/button_filter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button_filter" />
    </LinearLayout>

这是我的“Tab”附加到TabManger

public class GraphCategories extends SherlockFragmentActivity {
    GraphCategoriesFragment mCategoriesFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_graph_categories);

        if (savedInstanceState == null) {
            // Do first time initialization -- add initial fragment.
            mCategoriesFragment = GraphCategoriesFragment.newInstance(1);
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.add(R.id.fragment_graph_categories, mCategoriesFragment).commit();
        } else {
            //mStackLevel = savedInstanceState.getInt("level");
        }
    }

    @Override
    protected void onResume() {
        if(mCategoriesFragment != null) {
            //mCategoriesFragment.onResumeRedraw();
        }
    }
    //notice Inner class
    public static class GraphCategoriesFragment extends SherlockFragment {
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //View mChartView = inflater.inflate(R.layout.hello_world, container, false);
        View rlayout = inflater.inflate(R.layout.fragment_graph_categories, container, false);

        //? rlayout = new LinearLayout(getActivity());


        return rlayout;
        }   
    }
}

但是我不确定在片段onCreateView上输入什么,或者我的xml中是否需要FrameLayout? 我尝试了一些选项,但没想出来。

0 个答案:

没有答案