Android的achartengine简单的饼图 [英] Android achartengine simple pie chart

查看:105
本文介绍了Android的achartengine简单的饼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面的<一个href="http://web.archive.org/web/20100904224355/http://xebee.xebia.in/2010/08/31/exploring-android-charting-and-graphs-solutions/"相对=nofollow>一个在这个环节例子, 创建一个类,如下

I'm following an example in this link and created a class as below

public class aChartExample {

    public Intent execute(Context context) {
        int[] colors = new int[] { Color.RED, Color.YELLOW, Color.BLUE };
        DefaultRenderer renderer = buildCategoryRenderer(colors);

        CategorySeries categorySeries = new CategorySeries("Vehicles Chart");
        categorySeries.add("cars ", 30);
        categorySeries.add("trucks", 20);
        categorySeries.add("bikes ", 60);

        return ChartFactory.getPieChartIntent(context, categorySeries, renderer, null);
    }

    protected DefaultRenderer buildCategoryRenderer(int[] colors) {
        DefaultRenderer renderer = new DefaultRenderer();
        for (int color : colors) {
            SimpleSeriesRenderer r = new SimpleSeriesRenderer();
            r.setColor(color);
            renderer.addSeriesRenderer(r);
        }
        return renderer;
    }
}

和我打电话给它,当我的应用程序就开始在OnCreate我开始活动。

and I'm calling it when my app starts on my starting activity in the onCreate.

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

    Intent achartIntent = new aChartExample().execute(this);
    startActivity(achartIntent);
}

然后我包括achartengine-0.6.0.jar在我的项目。

I then included the achartengine-0.6.0.jar in my project.

当我运行它崩溃的startActivity线的应用程序。

When I run the app it crashes on the startActivity line.

不知道从哪里何去何从。

Not sure where to go from here.

推荐答案

你有没有在AndroidManifest.xml中添加此下方一行。如果这样,可以在发布错误信息,我想同例2天前为我工作。

Did you add this below line in AndroidManifest.xml. If so can you post the error message, I tried the same example 2 days ago and worked for me.

<activity android:name="org.achartengine.GraphicalActivity"> 

这篇关于Android的achartengine简单的饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆