我正在尝试使用GraphView库在我的应用程序上显示图表。代码非常简单:
package pizio.prova.it;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.GraphView.GraphViewData;
import com.jjoe64.graphview.GraphView.GraphViewSeries;
import com.jjoe64.graphview.LineGraphView;
public class ProvaGraphViewActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// init example series data
GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] {
new GraphViewData(1, 2.0d)
, new GraphViewData(2, 1.5d)
, new GraphViewData(3, 2.5d)
, new GraphViewData(4, 1.0d)
});
GraphView graphView = new LineGraphView(
this // context
, "GraphViewDemo" // heading
);
graphView.addSeries(exampleSeries); // data
LinearLayout layout = (LinearLayout) findViewById(R.id.graphLayout);
layout.addView(graphView);
}
}
此错误:
E/dalvikvm(1224): Could not find class 'com.jjoe64.graphview.GraphView $GraphViewSeries', referenced from method pizio.prova.it.ProvaGraphViewActivity.onCreate
然后这个致命的异常:
java.lang.NoClassDefFoundError: com.jjoe64.graphview.GraphView$GraphViewSeries
E/AndroidRuntime(1224): at pizio.prova.it.ProvaGraphViewActivity.onCreate(ProvaGraphViewActivity.java:22)
就是我得到的。为什么它不能到达我已经导入的类?
最佳答案
也许您可以尝试转到porject>properties>import and export。检查graphview jar文件并将其上移。完成此操作后,单击“确定”并清除项目,然后运行。
关于android - 找不到类GraphViewSeries,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9270041/