本文介绍了achartengine意图不会启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作是与chartengine lib中绘制用户数据的应用程序。
我有一个标签的应用和我的图表绘图工作从装载到标签的活动地方,但并非如此。
我不知道为什么,如果有人能帮助我吗?

I'm working on an app that plots user data with a chartengine lib.I have a tab application and my chart plot works anywhere but not from activities that load to tabs.I wonder why and if anyone can help me?

本作品:

public class DataActivity extends Activity {
static final int SERIES_NR = 3;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.data_form);
    XYMultipleSeriesRenderer renderer = getTruitonBarRenderer();
    myChartSettings(renderer);
    Intent i = ChartFactory.getBarChartIntent(DataActivity.this, getTruitonBarDataset(), renderer, Type.DEFAULT);
    startActivity(i);




}


 private XYMultipleSeriesDataset getTruitonBarDataset() {
        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        final int nr = 11;
        Random r = new Random();
        ArrayList<String> legendTitles = new ArrayList<String>();
        legendTitles.add("Sales");
        legendTitles.add("Expenses");
        legendTitles.add("age");
        for (int i = 0; i < SERIES_NR; i++) {
            CategorySeries series = new CategorySeries(legendTitles.get(i));
            for (int k = 0; k < nr; k++) {
                series.add(k+ r.nextInt() % 100);
            }
            dataset.addSeries(series.toXYSeries());
        }
        return dataset;
    }

    public XYMultipleSeriesRenderer getTruitonBarRenderer() {
        XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
        renderer.setAxisTitleTextSize(16);
        renderer.setChartTitleTextSize(20);
        renderer.setLabelsTextSize(15);
        renderer.setLegendTextSize(15);
        renderer.setMargins(new int[] { 30, 40, 15, 0 });
        SimpleSeriesRenderer r = new SimpleSeriesRenderer();
        r.setColor(Color.BLUE);
        renderer.addSeriesRenderer(r);

        r = new SimpleSeriesRenderer();
        r.setColor(Color.RED);
        renderer.addSeriesRenderer(r);

        r = new SimpleSeriesRenderer();
        r.setColor(Color.CYAN);
        renderer.addSeriesRenderer(r);

        return renderer;
    }

    private void myChartSettings(XYMultipleSeriesRenderer renderer) {
        renderer.setChartTitle("achart engine by mahdi tajik");
        renderer.setXAxisMin(0.5);
        renderer.setXAxisMax(10.5);
        renderer.setYAxisMin(0);
        renderer.setYAxisMax(210);
        renderer.addXTextLabel(1, "2010");
        renderer.addXTextLabel(2, "2011");
        renderer.addXTextLabel(3, "2012");
        renderer.addXTextLabel(4, "2013");
        renderer.addXTextLabel(5, "2013");
        renderer.addXTextLabel(6, "2013");
        renderer.addXTextLabel(7, "2012");
        renderer.addXTextLabel(8, "20123");
        renderer.addXTextLabel(9, "201223");
        renderer.addXTextLabel(10, "2022213");
        renderer.addXTextLabel(11, "20122223");
        renderer.setYLabelsAlign(Align.RIGHT);
        renderer.setBarSpacing(0.5);
        renderer.setXTitle("Years");
        renderer.setYTitle("Performance");
        renderer.setShowGrid(true);
        renderer.setGridColor(Color.GRAY);
        renderer.setXLabels(0); // sets the number of integer labels to appear
    }


}

但不会工作:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.static_form);

    initilizeUi();
}

private void plotWeekStatics(){
    XYMultipleSeriesRenderer renderer = getTruitonBarRenderer();
    myChartSettings(renderer);
    Intent i = ChartFactory.getBarChartIntent(StaticActivity.this, getTruitonBarDataset(), renderer, Type.DEFAULT);
    startActivity(i);

}
 private XYMultipleSeriesDataset getTruitonBarDataset() {
        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        final int nr = 11;
        Random r = new Random();
        ArrayList<String> legendTitles = new ArrayList<String>();
        legendTitles.add("Sales");
        legendTitles.add("Expenses");
        legendTitles.add("age");
        for (int i = 0; i < SERIES_NR; i++) {
            CategorySeries series = new CategorySeries(legendTitles.get(i));
            for (int k = 0; k < nr; k++) {
                series.add(k+ r.nextInt() % 100);
            }
            dataset.addSeries(series.toXYSeries());
        }
        return dataset;
    }

    public XYMultipleSeriesRenderer getTruitonBarRenderer() {
        XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
        renderer.setAxisTitleTextSize(16);
        renderer.setChartTitleTextSize(20);
        renderer.setLabelsTextSize(15);
        renderer.setLegendTextSize(15);
        renderer.setMargins(new int[] { 30, 40, 15, 0 });
        SimpleSeriesRenderer r = new SimpleSeriesRenderer();
        r.setColor(Color.BLUE);
        renderer.addSeriesRenderer(r);

        r = new SimpleSeriesRenderer();
        r.setColor(Color.RED);
        renderer.addSeriesRenderer(r);

        r = new SimpleSeriesRenderer();
        r.setColor(Color.CYAN);
        renderer.addSeriesRenderer(r);

        return renderer;
    }

    private void myChartSettings(XYMultipleSeriesRenderer renderer) {
        renderer.setChartTitle("achart engine by mahdi tajik");
        renderer.setXAxisMin(0.5);
        renderer.setXAxisMax(10.5);
        renderer.setYAxisMin(0);
        renderer.setYAxisMax(210);
        renderer.addXTextLabel(1, "2010");
        renderer.addXTextLabel(2, "2011");
        renderer.addXTextLabel(3, "2012");
        renderer.addXTextLabel(4, "2013");
        renderer.addXTextLabel(5, "2013");
        renderer.addXTextLabel(6, "2013");
        renderer.addXTextLabel(7, "2012");
        renderer.addXTextLabel(8, "20123");
        renderer.addXTextLabel(9, "201223");
        renderer.addXTextLabel(10, "2022213");
        renderer.addXTextLabel(11, "20122223");
        renderer.setYLabelsAlign(Align.RIGHT);
        renderer.setBarSpacing(0.5);
        renderer.setXTitle("Years");
        renderer.setYTitle("Performance");
        renderer.setShowGrid(true);
        renderer.setGridColor(Color.GRAY);
        renderer.setXLabels(0); // sets the number of integer labels to appear
    }

为什么在一个活动同code的工作不是在另一
我必须说,第二个code样品中加载到tabactivity。

Why does the same code work in one activity not in anotherI must say that in the second code sample it loads to a tabactivity.

推荐答案

我终于被我解决这个问题。
问题是我不会定义清单文件achartactivity是这样的:

i finally i solve the problem.the problem was i wont define achartactivity in manifest file like this:

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

和与添加这个我的应用程序正常工作。 :)

and with adding this my app works correctly. :)

这篇关于achartengine意图不会启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 04:33