Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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 eclipse示例_Android_Eclipse_Charts - Fatal编程技术网

一个自由图表Android eclipse示例

一个自由图表Android eclipse示例,android,eclipse,charts,Android,Eclipse,Charts,我正试图使用AFreeChart在我的活动中显示一个图表,我查阅了大量的互联网文档,但我没有找到任何完整的示例,我的意思是如何构建一个图表并在我的布局中显示它,我需要在GUI中显示它(和GUI中的图像一样),我正在使用eclipse(android 4.2)来显示它 有人知道如何在android中使用AfreeChart吗?谢谢好的,因为这是一篇较老的帖子,我不确定你是否能找到这个问题的答案。这就是在活动中显示自由图表所需完成的操作 创建一个扩展ImageView的自定义视图,如blelow p

我正试图使用AFreeChart在我的活动中显示一个图表,我查阅了大量的互联网文档,但我没有找到任何完整的示例,我的意思是如何构建一个图表并在我的布局中显示它,我需要在GUI中显示它(和GUI中的图像一样),我正在使用eclipse(android 4.2)来显示它


有人知道如何在android中使用AfreeChart吗?谢谢

好的,因为这是一篇较老的帖子,我不确定你是否能找到这个问题的答案。这就是在活动中显示自由图表所需完成的操作

  • 创建一个扩展ImageView的自定义视图,如blelow

    public class ChartView extends ImageView
    {
        private Bitmap              bitmap;
        private RectShape           rectArea;
        private Canvas              canvas;
        private AFreeChart          chart;
    
        public ChartView( Context context, AttributeSet attributeSet )
        {
            super(context, attributeSet);
        }
    
        public ChartView( Context context )
        {
            super(context);
            intChart();
        }
    
        private void intChart()
        {
            //Setting different width and height based on the orientation.
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
            {
                bitmap = Bitmap.createBitmap(400, 200, Bitmap.Config.ARGB_8888);
                rectArea = new RectShape(0.0, 0.0, 400, 200);
            }
            else
            {
                bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
                rectArea = new RectShape(0.0, 0.0, 200, 200);
            }
        }
    
        public void drawChart( AFreeChart chart )
        {
            canvas = new Canvas(bitmap);
            this.chart = chart;             
            this.chart.draw(canvas, rectArea);
            setImageBitmap(bitmap);
        }
    
        @Override
        protected void onDraw( Canvas canvas )
        {
            super.onDraw(canvas);               
        }
    }
    
  • 创建一个活动,如下所示,所有人都设置为开始。我假设您已经创建了要传递给视图的AFreeChart对象

        public class ChartActivity extends Activity
        {
            @Override
            protected void onCreate( Bundle savedInstanceState )
            {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.chart);
    
                ViewGroup viewGroup = (ViewGroup)getWindow().getDecorView().findViewById(android.R.id.content);
    
                ChartView chartView = new ChartView(this);
    
                chartView.drawChart(ChartFactory.createChart()/*Returns AFreechart object*/);       
    
                viewGroup.addView(chartView);
    
            }
        }
    
  • chart.xml

            <?xml version="1.0" encoding="utf-8"?>
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >
    
            </LinearLayout>
    
    
    
  • 希望这有助于

    使用适当的标签(android)并重写您的问题,因为如果问题仍然像现在一样,它将被关闭。