gpt4 book ai didi

android - achartengine Intent 不会启动

转载 作者:行者123 更新时间:2023-11-30 03:20:34 25 4
gpt4 key购买 nike

我正在开发一款使用图表引擎库绘制用户数据的应用程序。我有一个选项卡应用程序,我的图表可以在任何地方工作,但不能从加载到选项卡的 Activity 中工作。我想知道为什么以及是否有人可以帮助我?

这个有效:

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
}

为什么相同的代码在一个 Activity 中有效,而在另一个 Activity 中却无效我必须说,在第二个代码示例中,它加载到一个 tabactivity。

最佳答案

我终于解决了这个问题。问题是我不会像这样在 list 文件中定义 achartactivity:

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

添加这个后,我的应用程序可以正常运行。 :)

关于android - achartengine Intent 不会启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19225340/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com