1

我正在使用 ViewPagerIndicator 的样式选项卡显示 ACE 图表 第一个显示的图表总是可以的。但是当您水平滑动到第二页时,第二个图表显示不好。你只有半张图表

我不知道如何在调用 ACE 之前使视图或其他技巧无效以强制完全显示

任何方向表示赞赏

public class Analytics extends FragmentActivity
{
    private List<String> pages;

    FragmentPagerAdapter mAdapter;
    ViewPager mPager;
    PageIndicator mIndicator;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        // set layout
        setContentView(R.layout.analytics);

        // set content
        pages = new ArrayList<String>();
        pages.add("history");
        pages.add("category");
        pages.add("cost");

        // set global objects
        mAdapter = new GoogleMusicAdapter(getSupportFragmentManager());

        mPager = (ViewPager)findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);

        mIndicator = (TabPageIndicator)findViewById(R.id.indicator);
        mIndicator.setViewPager(mPager);
    }

    class GoogleMusicAdapter extends FragmentPagerAdapter
    {
        public GoogleMusicAdapter(FragmentManager fm)
        {
            super(fm);
        }

        @Override
        public Fragment getItem(int position)
        {
            return AnalyticsFragment.newInstance(pages.get(position));
        }

        @Override
        public int getCount()
        {
        return pages.size();
        }

        @Override
        public CharSequence getPageTitle(int position)
        {
        return pages.get(position);
        }

    }

}

和带有摘要代码的片段类

public final class AnalyticsFragment extends Fragment
{
    private static final String KEY_CONTENT = "TestFragment:Content";
    private String content;

    public static AnalyticsFragment newInstance(String mContent)
    {
        AnalyticsFragment fragment = new AnalyticsFragment();        
        fragment.content = mContent;
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
            content = savedInstanceState.getString(KEY_CONTENT);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        LinearLayout layout = new LinearLayout(getActivity());
        Charts chart = new Charts(getActivity());
        GraphicalView v;

        if ("history".equals(content)) {
            v = ChartFactory.getBarChartView(context, dataset, renderer, Type.DEFAULT);
        } else {
            v = ChartFactory.getPieChartView(context, dataset, renderer);
        }

        layout.addView(v);        
        return layout;
    }

    @Override
    public void onSaveInstanceState(Bundle outState)
    {
        super.onSaveInstanceState(outState);
        outState.putString(KEY_CONTENT, content);
    }
}

版本:viewpagerindicator 2.3.1,achartengine 1.0.0

一张图值一千字: https ://docs.google.com/open?id=0BxbpQM-2XoKYM1NZYmRLUnY3cWs

4

1 回答 1

6

您可以通过调用使图表无效:

mChartView.repaint();

您可能还想试试这个:

mRenderer.setInScroll(true);
于 2012-07-15T21:03:19.973 回答