Java 实例化异常:can';t使用aChartEngine实例化类

Java 实例化异常:can';t使用aChartEngine实例化类,java,android,constructor,achartengine,Java,Android,Constructor,Achartengine,我正在尝试使用aChartEngine库()制作一个Android应用程序 我已经读了很多关于“无空构造函数”的话题,但是没有一个能解决我的问题 我正在尝试在单击列表项后启动新活动 我这样开始活动: private void addClickList() { diveList.setOnItemClickListener(new OnItemClickListener() { @Override public void onIte

我正在尝试使用aChartEngine库()制作一个Android应用程序

我已经读了很多关于“无空构造函数”的话题,但是没有一个能解决我的问题

我正在尝试在单击列表项后启动新活动

我这样开始活动:

private void addClickList() {
        diveList.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                Intent intent = new Intent(DiveLogActi.this, DiveDetailActi.class);
                intent.putExtra(EXTRA_ID, id);  
                startActivity(intent);
            }               
        });
}
public DiveDetailActi(Bundle savedInstanceState) {
        // TODO Auto-generated constructor stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.divedetail_acti);
        Intent intent = getIntent();
        idInDb = intent.getLongExtra(DiveLogActi.EXTRA_ID, 0);                  
        getDepthGraph();
}


private void getDepthGraph()
{
    LineGraph bar = new LineGraph();
    GraphicalView gView = bar.getView(this);

    LinearLayout layout = (LinearLayout) findViewById(R.id.chartDepth);
    layout.addView(gView);
}
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <ImageView
                android:id="@+id/diveImage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:layout_marginLeft="18dp"
                android:layout_marginTop="22dp"
                android:adjustViewBounds="true"
                android:maxHeight="150dp"
                android:maxWidth="150dp"
                android:src="@drawable/shark" />

            <TextView
                android:id="@+id/dateFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/diveImage"
                android:layout_alignLeft="@+id/diveNumberFromDb"
                android:layout_marginBottom="20dp"
                android:text="31/12/14"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/diveNumberFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/diveImage"
                android:layout_marginLeft="15dp"
                android:layout_marginTop="22dp"
                android:layout_toRightOf="@+id/diveImage"
                android:text="Dive 1"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/placeFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/diveImage"
                android:layout_below="@+id/diveImage"
                android:paddingBottom="5dp"
                android:paddingTop="5dp"
                android:text="Ephec, Louvain-la-Neuve"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <LinearLayout
                android:id="@+id/chartDepth"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/placeFromDb"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

            <LinearLayout
                android:id="@+id/chartTemp"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/chartDepth"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

        </RelativeLayout>
    </LinearLayout>
</ScrollView>
public class LineGraph{

    public GraphicalView getView(Context context) {

        // Our first data
        int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y =  { 30, 34, 45, 57, 77, 89, 100, 111 ,123 ,145 }; // y values!
        TimeSeries series = new TimeSeries("Line1"); 
        for( int i = 0; i < x.length; i++)
        {
            series.add(x[i], y[i]);
        }

        // Our second data
        int[] x2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y2 =  { 145, 123, 111, 100, 89, 77, 57, 45, 34, 30}; // y values!
        TimeSeries series2 = new TimeSeries("Line2"); 
        for( int i = 0; i < x2.length; i++)
        {
            series2.add(x2[i], y2[i]);
        }

        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        dataset.addSeries(series);
        dataset.addSeries(series2);

        XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); // Holds a collection of XYSeriesRenderer and customizes the graph
        XYSeriesRenderer renderer = new XYSeriesRenderer(); // This will be used to customize line 1
        XYSeriesRenderer renderer2 = new XYSeriesRenderer(); // This will be used to customize line 2
        mRenderer.addSeriesRenderer(renderer);
        mRenderer.addSeriesRenderer(renderer2);

        // Customization time for line 1!
        renderer.setColor(Color.WHITE);
        renderer.setPointStyle(PointStyle.SQUARE);
        renderer.setFillPoints(true);
        // Customization time for line 2!
        renderer2.setColor(Color.YELLOW);
        renderer2.setPointStyle(PointStyle.DIAMOND);
        renderer2.setFillPoints(true);


        return ChartFactory.getBarChartView(context, dataset,mRenderer, Type.DEFAULT);

    }

}
<activity
    android:name="com.example.arduinodivecompanion.DiveDetailActi"
    android:label="@string/diveDetail" >
</activity>

<activity 
    android:name="org.achartengine.GraphicalActivity" >
</activity>
divedeail\u acti.xml看起来是这样的:

private void addClickList() {
        diveList.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                Intent intent = new Intent(DiveLogActi.this, DiveDetailActi.class);
                intent.putExtra(EXTRA_ID, id);  
                startActivity(intent);
            }               
        });
}
public DiveDetailActi(Bundle savedInstanceState) {
        // TODO Auto-generated constructor stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.divedetail_acti);
        Intent intent = getIntent();
        idInDb = intent.getLongExtra(DiveLogActi.EXTRA_ID, 0);                  
        getDepthGraph();
}


private void getDepthGraph()
{
    LineGraph bar = new LineGraph();
    GraphicalView gView = bar.getView(this);

    LinearLayout layout = (LinearLayout) findViewById(R.id.chartDepth);
    layout.addView(gView);
}
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <ImageView
                android:id="@+id/diveImage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:layout_marginLeft="18dp"
                android:layout_marginTop="22dp"
                android:adjustViewBounds="true"
                android:maxHeight="150dp"
                android:maxWidth="150dp"
                android:src="@drawable/shark" />

            <TextView
                android:id="@+id/dateFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/diveImage"
                android:layout_alignLeft="@+id/diveNumberFromDb"
                android:layout_marginBottom="20dp"
                android:text="31/12/14"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/diveNumberFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/diveImage"
                android:layout_marginLeft="15dp"
                android:layout_marginTop="22dp"
                android:layout_toRightOf="@+id/diveImage"
                android:text="Dive 1"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/placeFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/diveImage"
                android:layout_below="@+id/diveImage"
                android:paddingBottom="5dp"
                android:paddingTop="5dp"
                android:text="Ephec, Louvain-la-Neuve"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <LinearLayout
                android:id="@+id/chartDepth"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/placeFromDb"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

            <LinearLayout
                android:id="@+id/chartTemp"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/chartDepth"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

        </RelativeLayout>
    </LinearLayout>
</ScrollView>
public class LineGraph{

    public GraphicalView getView(Context context) {

        // Our first data
        int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y =  { 30, 34, 45, 57, 77, 89, 100, 111 ,123 ,145 }; // y values!
        TimeSeries series = new TimeSeries("Line1"); 
        for( int i = 0; i < x.length; i++)
        {
            series.add(x[i], y[i]);
        }

        // Our second data
        int[] x2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y2 =  { 145, 123, 111, 100, 89, 77, 57, 45, 34, 30}; // y values!
        TimeSeries series2 = new TimeSeries("Line2"); 
        for( int i = 0; i < x2.length; i++)
        {
            series2.add(x2[i], y2[i]);
        }

        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        dataset.addSeries(series);
        dataset.addSeries(series2);

        XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); // Holds a collection of XYSeriesRenderer and customizes the graph
        XYSeriesRenderer renderer = new XYSeriesRenderer(); // This will be used to customize line 1
        XYSeriesRenderer renderer2 = new XYSeriesRenderer(); // This will be used to customize line 2
        mRenderer.addSeriesRenderer(renderer);
        mRenderer.addSeriesRenderer(renderer2);

        // Customization time for line 1!
        renderer.setColor(Color.WHITE);
        renderer.setPointStyle(PointStyle.SQUARE);
        renderer.setFillPoints(true);
        // Customization time for line 2!
        renderer2.setColor(Color.YELLOW);
        renderer2.setPointStyle(PointStyle.DIAMOND);
        renderer2.setFillPoints(true);


        return ChartFactory.getBarChartView(context, dataset,mRenderer, Type.DEFAULT);

    }

}
<activity
    android:name="com.example.arduinodivecompanion.DiveDetailActi"
    android:label="@string/diveDetail" >
</activity>

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

在折线图中我有这样一个:

private void addClickList() {
        diveList.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                Intent intent = new Intent(DiveLogActi.this, DiveDetailActi.class);
                intent.putExtra(EXTRA_ID, id);  
                startActivity(intent);
            }               
        });
}
public DiveDetailActi(Bundle savedInstanceState) {
        // TODO Auto-generated constructor stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.divedetail_acti);
        Intent intent = getIntent();
        idInDb = intent.getLongExtra(DiveLogActi.EXTRA_ID, 0);                  
        getDepthGraph();
}


private void getDepthGraph()
{
    LineGraph bar = new LineGraph();
    GraphicalView gView = bar.getView(this);

    LinearLayout layout = (LinearLayout) findViewById(R.id.chartDepth);
    layout.addView(gView);
}
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <ImageView
                android:id="@+id/diveImage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:layout_marginLeft="18dp"
                android:layout_marginTop="22dp"
                android:adjustViewBounds="true"
                android:maxHeight="150dp"
                android:maxWidth="150dp"
                android:src="@drawable/shark" />

            <TextView
                android:id="@+id/dateFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/diveImage"
                android:layout_alignLeft="@+id/diveNumberFromDb"
                android:layout_marginBottom="20dp"
                android:text="31/12/14"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/diveNumberFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/diveImage"
                android:layout_marginLeft="15dp"
                android:layout_marginTop="22dp"
                android:layout_toRightOf="@+id/diveImage"
                android:text="Dive 1"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/placeFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/diveImage"
                android:layout_below="@+id/diveImage"
                android:paddingBottom="5dp"
                android:paddingTop="5dp"
                android:text="Ephec, Louvain-la-Neuve"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <LinearLayout
                android:id="@+id/chartDepth"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/placeFromDb"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

            <LinearLayout
                android:id="@+id/chartTemp"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/chartDepth"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

        </RelativeLayout>
    </LinearLayout>
</ScrollView>
public class LineGraph{

    public GraphicalView getView(Context context) {

        // Our first data
        int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y =  { 30, 34, 45, 57, 77, 89, 100, 111 ,123 ,145 }; // y values!
        TimeSeries series = new TimeSeries("Line1"); 
        for( int i = 0; i < x.length; i++)
        {
            series.add(x[i], y[i]);
        }

        // Our second data
        int[] x2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y2 =  { 145, 123, 111, 100, 89, 77, 57, 45, 34, 30}; // y values!
        TimeSeries series2 = new TimeSeries("Line2"); 
        for( int i = 0; i < x2.length; i++)
        {
            series2.add(x2[i], y2[i]);
        }

        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        dataset.addSeries(series);
        dataset.addSeries(series2);

        XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); // Holds a collection of XYSeriesRenderer and customizes the graph
        XYSeriesRenderer renderer = new XYSeriesRenderer(); // This will be used to customize line 1
        XYSeriesRenderer renderer2 = new XYSeriesRenderer(); // This will be used to customize line 2
        mRenderer.addSeriesRenderer(renderer);
        mRenderer.addSeriesRenderer(renderer2);

        // Customization time for line 1!
        renderer.setColor(Color.WHITE);
        renderer.setPointStyle(PointStyle.SQUARE);
        renderer.setFillPoints(true);
        // Customization time for line 2!
        renderer2.setColor(Color.YELLOW);
        renderer2.setPointStyle(PointStyle.DIAMOND);
        renderer2.setFillPoints(true);


        return ChartFactory.getBarChartView(context, dataset,mRenderer, Type.DEFAULT);

    }

}
<activity
    android:name="com.example.arduinodivecompanion.DiveDetailActi"
    android:label="@string/diveDetail" >
</activity>

<activity 
    android:name="org.achartengine.GraphicalActivity" >
</activity>
公共类线图{
公共图形视图getView(上下文){
//我们的第一个数据
int[]x={1,2,3,4,5,6,7,8,9,10};//x值!
int[]y={30,34,45,57,77,89100111123145};//y值!
TimeSeries系列=新的TimeSeries(“Line1”);
对于(int i=0;i
我将所有需要的活动都放在清单中:

private void addClickList() {
        diveList.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                Intent intent = new Intent(DiveLogActi.this, DiveDetailActi.class);
                intent.putExtra(EXTRA_ID, id);  
                startActivity(intent);
            }               
        });
}
public DiveDetailActi(Bundle savedInstanceState) {
        // TODO Auto-generated constructor stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.divedetail_acti);
        Intent intent = getIntent();
        idInDb = intent.getLongExtra(DiveLogActi.EXTRA_ID, 0);                  
        getDepthGraph();
}


private void getDepthGraph()
{
    LineGraph bar = new LineGraph();
    GraphicalView gView = bar.getView(this);

    LinearLayout layout = (LinearLayout) findViewById(R.id.chartDepth);
    layout.addView(gView);
}
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <ImageView
                android:id="@+id/diveImage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:layout_marginLeft="18dp"
                android:layout_marginTop="22dp"
                android:adjustViewBounds="true"
                android:maxHeight="150dp"
                android:maxWidth="150dp"
                android:src="@drawable/shark" />

            <TextView
                android:id="@+id/dateFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/diveImage"
                android:layout_alignLeft="@+id/diveNumberFromDb"
                android:layout_marginBottom="20dp"
                android:text="31/12/14"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/diveNumberFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/diveImage"
                android:layout_marginLeft="15dp"
                android:layout_marginTop="22dp"
                android:layout_toRightOf="@+id/diveImage"
                android:text="Dive 1"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/placeFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/diveImage"
                android:layout_below="@+id/diveImage"
                android:paddingBottom="5dp"
                android:paddingTop="5dp"
                android:text="Ephec, Louvain-la-Neuve"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <LinearLayout
                android:id="@+id/chartDepth"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/placeFromDb"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

            <LinearLayout
                android:id="@+id/chartTemp"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/chartDepth"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

        </RelativeLayout>
    </LinearLayout>
</ScrollView>
public class LineGraph{

    public GraphicalView getView(Context context) {

        // Our first data
        int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y =  { 30, 34, 45, 57, 77, 89, 100, 111 ,123 ,145 }; // y values!
        TimeSeries series = new TimeSeries("Line1"); 
        for( int i = 0; i < x.length; i++)
        {
            series.add(x[i], y[i]);
        }

        // Our second data
        int[] x2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y2 =  { 145, 123, 111, 100, 89, 77, 57, 45, 34, 30}; // y values!
        TimeSeries series2 = new TimeSeries("Line2"); 
        for( int i = 0; i < x2.length; i++)
        {
            series2.add(x2[i], y2[i]);
        }

        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        dataset.addSeries(series);
        dataset.addSeries(series2);

        XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); // Holds a collection of XYSeriesRenderer and customizes the graph
        XYSeriesRenderer renderer = new XYSeriesRenderer(); // This will be used to customize line 1
        XYSeriesRenderer renderer2 = new XYSeriesRenderer(); // This will be used to customize line 2
        mRenderer.addSeriesRenderer(renderer);
        mRenderer.addSeriesRenderer(renderer2);

        // Customization time for line 1!
        renderer.setColor(Color.WHITE);
        renderer.setPointStyle(PointStyle.SQUARE);
        renderer.setFillPoints(true);
        // Customization time for line 2!
        renderer2.setColor(Color.YELLOW);
        renderer2.setPointStyle(PointStyle.DIAMOND);
        renderer2.setFillPoints(true);


        return ChartFactory.getBarChartView(context, dataset,mRenderer, Type.DEFAULT);

    }

}
<activity
    android:name="com.example.arduinodivecompanion.DiveDetailActi"
    android:label="@string/diveDetail" >
</activity>

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

我还将aChartEngine.jar添加到构建路径:

private void addClickList() {
        diveList.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                Intent intent = new Intent(DiveLogActi.this, DiveDetailActi.class);
                intent.putExtra(EXTRA_ID, id);  
                startActivity(intent);
            }               
        });
}
public DiveDetailActi(Bundle savedInstanceState) {
        // TODO Auto-generated constructor stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.divedetail_acti);
        Intent intent = getIntent();
        idInDb = intent.getLongExtra(DiveLogActi.EXTRA_ID, 0);                  
        getDepthGraph();
}


private void getDepthGraph()
{
    LineGraph bar = new LineGraph();
    GraphicalView gView = bar.getView(this);

    LinearLayout layout = (LinearLayout) findViewById(R.id.chartDepth);
    layout.addView(gView);
}
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <ImageView
                android:id="@+id/diveImage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:layout_marginLeft="18dp"
                android:layout_marginTop="22dp"
                android:adjustViewBounds="true"
                android:maxHeight="150dp"
                android:maxWidth="150dp"
                android:src="@drawable/shark" />

            <TextView
                android:id="@+id/dateFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/diveImage"
                android:layout_alignLeft="@+id/diveNumberFromDb"
                android:layout_marginBottom="20dp"
                android:text="31/12/14"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/diveNumberFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/diveImage"
                android:layout_marginLeft="15dp"
                android:layout_marginTop="22dp"
                android:layout_toRightOf="@+id/diveImage"
                android:text="Dive 1"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/placeFromDb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/diveImage"
                android:layout_below="@+id/diveImage"
                android:paddingBottom="5dp"
                android:paddingTop="5dp"
                android:text="Ephec, Louvain-la-Neuve"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <LinearLayout
                android:id="@+id/chartDepth"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/placeFromDb"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

            <LinearLayout
                android:id="@+id/chartTemp"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignLeft="@+id/chartDepth"
                android:layout_below="@+id/placeFromDb"
                android:layout_marginTop="14dp" >
            </LinearLayout>

        </RelativeLayout>
    </LinearLayout>
</ScrollView>
public class LineGraph{

    public GraphicalView getView(Context context) {

        // Our first data
        int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y =  { 30, 34, 45, 57, 77, 89, 100, 111 ,123 ,145 }; // y values!
        TimeSeries series = new TimeSeries("Line1"); 
        for( int i = 0; i < x.length; i++)
        {
            series.add(x[i], y[i]);
        }

        // Our second data
        int[] x2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
        int[] y2 =  { 145, 123, 111, 100, 89, 77, 57, 45, 34, 30}; // y values!
        TimeSeries series2 = new TimeSeries("Line2"); 
        for( int i = 0; i < x2.length; i++)
        {
            series2.add(x2[i], y2[i]);
        }

        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        dataset.addSeries(series);
        dataset.addSeries(series2);

        XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); // Holds a collection of XYSeriesRenderer and customizes the graph
        XYSeriesRenderer renderer = new XYSeriesRenderer(); // This will be used to customize line 1
        XYSeriesRenderer renderer2 = new XYSeriesRenderer(); // This will be used to customize line 2
        mRenderer.addSeriesRenderer(renderer);
        mRenderer.addSeriesRenderer(renderer2);

        // Customization time for line 1!
        renderer.setColor(Color.WHITE);
        renderer.setPointStyle(PointStyle.SQUARE);
        renderer.setFillPoints(true);
        // Customization time for line 2!
        renderer2.setColor(Color.YELLOW);
        renderer2.setPointStyle(PointStyle.DIAMOND);
        renderer2.setFillPoints(true);


        return ChartFactory.getBarChartView(context, dataset,mRenderer, Type.DEFAULT);

    }

}
<activity
    android:name="com.example.arduinodivecompanion.DiveDetailActi"
    android:label="@string/diveDetail" >
</activity>

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

最后,我尝试添加一个空构造函数,但新活动只显示一个空白页。

我将此作为输出:

05-20 17:06:11.351: E/AndroidRuntime(24830): FATAL EXCEPTION: main
05-20 17:06:11.351: E/AndroidRuntime(24830): Process: com.example.arduinodivecompanion, PID: 24830
05-20 17:06:11.351: E/AndroidRuntime(24830): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.arduinodivecompanion/com.example.arduinodivecompanion.DiveDetailActi}: java.lang.InstantiationException: can't instantiate class com.example.arduinodivecompanion.DiveDetailActi; no empty constructor
05-20 17:06:11.351: E/AndroidRuntime(24830):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at android.os.Handler.dispatchMessage(Handler.java:102)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at android.os.Looper.loop(Looper.java:136)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at android.app.ActivityThread.main(ActivityThread.java:5017)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at java.lang.reflect.Method.invokeNative(Native Method)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at java.lang.reflect.Method.invoke(Method.java:515)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at dalvik.system.NativeStart.main(Native Method)
05-20 17:06:11.351: E/AndroidRuntime(24830): Caused by: java.lang.InstantiationException: can't instantiate class com.example.arduinodivecompanion.DiveDetailActi; no empty constructor
05-20 17:06:11.351: E/AndroidRuntime(24830):    at java.lang.Class.newInstanceImpl(Native Method)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at java.lang.Class.newInstance(Class.java:1208)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
05-20 17:06:11.351: E/AndroidRuntime(24830):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
05-20 17:06:11.351: E/AndroidRuntime(24830):    ... 11 more
05-20 17:06:12.971: I/Adreno-EGL(24864): <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13
05-20 17:06:12.991: D/OpenGLRenderer(24864): Enabling debug mode 0
05-20 17:06:11.351:E/AndroidRuntime(24830):致命异常:main
05-20 17:06:11.351:E/AndroidRuntime(24830):进程:com.example.arduinodivecompanion,PID:24830
05-20 17:06:11.351:E/AndroidRuntime(24830):java.lang.RuntimeException:无法实例化活动组件信息{com.example.arduinodivecompanion/com.example.arduinodivecompanion.DiveDetailActivi}:java.lang.InstanceException:无法实例化类com.example.arduinodivecompanion.DiveDetailActivi;没有空构造函数
05-20 17:06:11.351:E/AndroidRuntime(24830):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)上
05-20 17:06:11.351:E/AndroidRuntime(24830):位于android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-20 17:06:11.351:E/AndroidRuntime(24830):在android.app.ActivityThread.access$800(ActivityThread.java:135)
05-20 17:06:11.351:E/AndroidRuntime(24830):在android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-20 17:06:11.351:E/AndroidRuntime(24830):位于android.os.Handler.dispatchMessage(Handler.java:102)
05-20 17:06:11.351:E/AndroidRuntime(24830):在android.os.Looper.loop(Looper.java:136)
05-20 17:06:11.351:E/AndroidRuntime(24830):位于android.app.ActivityThread.main(ActivityThread.java:5017)
05-20 17:06:11.351:E/AndroidRuntime(24830):位于java.lang.reflect.Method.Invokenactive(本机方法)
05-20 17:06:11.351:E/AndroidRuntime(24830):位于java.lang.reflect.Method.invoke(Method.java:515)
05-20 17:06:11.351:E/AndroidRuntime(24830):在com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-20 17:06:11.351:E/AndroidRuntime(24830):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-20 17:06:11.351:E/AndroidRuntime(24830):在dalvik.system.NativeStart.main(本机方法)
05-20 17:06:11.351:E/AndroidRuntime(24830):原因:java.lang.InstantiationException:无法实例化类com.example.arduinodivecompanion.DiveDetailActivi;没有空构造函数
05-20 17:06:11.351:E/AndroidRuntime(24830):位于java.lang.Class.newInstanceImpl(本机方法)
05-20 17:06:11.351:E/AndroidRuntime(24830):位于java.lang.Class.newInstance(Class.java:1208)
05-20 17:06:11.351:E/AndroidRuntime(24830):在android.app.Instrumentation.newActivity(Instrumentation.java:1061)上
05-20 17:06:11.351:E/AndroidRuntime(24830):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)上
05-20 17:06:11.351:E/AndroidRuntime(24830):。。。还有11个
05-20 17:06:12.971:I/Adreno EGL(24864)::EGL 1.4高通公司版本:I0404C4692AFB8623F95C43AEB6D5E13ED4B30DDB日期:2013年6月11日
05-20 17:06:12.991:D/OpenGLRenderer(24864):启用调试模式0

有人能帮我吗?

是否每个调用意图的活动都必须在清单中包含这些行
Woops,初学者的错误,我只是写了
public-DiveDetailActi(Bundle-savedInstanceState)
而不是
protectedvoid-onCreate(Bundle-savedInstanceState)