Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将可单击的项目添加到一个工作流折线图中?_Android_Achartengine - Fatal编程技术网

Android 如何将可单击的项目添加到一个工作流折线图中?

Android 如何将可单击的项目添加到一个工作流折线图中?,android,achartengine,Android,Achartengine,示例中有以下代码: /** * Copyright (C) 2009, 2010 SC 4ViewSoft SRL * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *

示例中有以下代码:

/**
 * Copyright (C) 2009, 2010 SC 4ViewSoft SRL
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.achartengine.chartdemo.demo.chart;

import java.util.ArrayList;
import java.util.List;

import org.achartengine.ChartFactory;
import org.achartengine.chart.PointStyle;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint.Align;

/**
 * Average temperature demo chart.
 */
public class AverageTemperatureChart extends AbstractDemoChart {
  /**
   * Returns the chart name.
   * 
   * @return the chart name
   */
  public String getName() {
    return "Average temperature";
  }

  /**
   * Returns the chart description.
   * 
   * @return the chart description
   */
  public String getDesc() {
    return "The average temperature in 4 Greek islands (line chart)";
  }

  /**
   * Executes the chart demo.
   * 
   * @param context the context
   * @return the built intent
   */
  public Intent execute(Context context) {
    String[] titles = new String[] { "Crete", "Corfu", "Thassos", "Skiathos" };
    List<double[]> x = new ArrayList<double[]>();
    for (int i = 0; i < titles.length; i++) {
      x.add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
    }
    List<double[]> values = new ArrayList<double[]>();
    values.add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2,
        13.9 });
    values.add(new double[] { 10, 10, 12, 15, 20, 24, 26, 26, 23, 18, 14, 11 });
    values.add(new double[] { 5, 5.3, 8, 12, 17, 22, 24.2, 24, 19, 15, 9, 6 });
    values.add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 });
    int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.CYAN, Color.YELLOW };
    PointStyle[] styles = new PointStyle[] { PointStyle.CIRCLE, PointStyle.DIAMOND,
        PointStyle.TRIANGLE, PointStyle.SQUARE };
    XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
    int length = renderer.getSeriesRendererCount();
    for (int i = 0; i < length; i++) {
      ((XYSeriesRenderer) renderer.getSeriesRendererAt(i)).setFillPoints(true);
    }
    setChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, -10, 40,
        Color.LTGRAY, Color.LTGRAY);
    renderer.setXLabels(12);
    renderer.setYLabels(10);
    renderer.setShowGrid(true);
    renderer.setXLabelsAlign(Align.RIGHT);
    renderer.setYLabelsAlign(Align.RIGHT);
    renderer.setZoomButtonsVisible(true);
    renderer.setPanLimits(new double[] { -10, 20, -10, 40 });
    renderer.setZoomLimits(new double[] { -10, 20, -10, 40 });

    Intent intent = ChartFactory.getLineChartIntent(context, buildDataset(titles, x, values),
        renderer, "Average temperature");
    return intent;
  }

}
/**
*版权所有(C)2009、2010 SC 4ViewSoft SRL
*  
*根据Apache许可证2.0版(以下简称“许可证”)获得许可;
*除非遵守许可证,否则不得使用此文件。
*您可以通过以下方式获得许可证副本:
*  
*      http://www.apache.org/licenses/LICENSE-2.0
*  
*除非适用法律要求或书面同意,软件
*根据许可证进行的分发是按“原样”进行分发的,
*无任何明示或暗示的保证或条件。
*请参阅许可证以了解管理权限和权限的特定语言
*许可证下的限制。
*/
包org.achartengine.chartdemo.demo.chart;
导入java.util.ArrayList;
导入java.util.List;
导入org.achartengine.ChartFactory;
导入org.achartengine.chart.PointStyle;
导入org.achartengine.renderer.XYMultipleSeriesRenderer;
导入org.achartengine.renderer.XYSeriesRenderer;
导入android.content.Context;
导入android.content.Intent;
导入android.graphics.Color;
导入android.graphics.Paint.Align;
/**
*平均温度演示图。
*/
公共类平均温度Chart扩展抽象人口图表{
/**
*返回图表名称。
* 
*@返回图表名称
*/
公共字符串getName(){
返回“平均温度”;
}
/**
*返回图表说明。
* 
*@返回图表说明
*/
公共字符串getDesc(){
返回“希腊4个岛屿的平均温度(折线图)”;
}
/**
*执行图表演示。
* 
*@param context上下文
*@返回建造意图
*/
公共意图执行(上下文){
字符串[]标题=新字符串[]{“克里特”、“科孚”、“塔索斯”、“斯基亚索斯”};
列表x=新的ArrayList();
对于(int i=0;i
这是来自ACharEngine库示例的代码,只是画了一个简单的折线图。
是否可以将侦听器设置为按行单击?这是不可能的,可能有什么方法可以设置侦听器按点单击

这是可能的。看看例子中的类,第157到179行


谢谢。但是我怎样才能为我的任务修复它呢?我不使用视图类。是否有用于set listener的接口?如果不使用视图,则无法使用。如果查看我在帖子中插入的代码,我使用Intent执行图表。我怎样才能使用视图而不是意图?如果你看一下我在回答中提到的代码,你就会知道是如何使用的。@Dan我认为你回答中的链接被编辑了,第217行不存在。我对这个话题很感兴趣。是否有我可以参考的链接、信息或参考资料?