public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
// Inflate the layout for this fragment
View rootView= inflater.inflate(R.layout.fragment_graph, container, false);
GraphView graph = (GraphView) rootView.findViewById(R.id.graph);
BarGraphSeries<DataPoint> series = new BarGraphSeries<>(new DataPoint[] {
new DataPoint(0, 1),
new DataPoint(1, 5),
new DataPoint(2, 3),
new DataPoint(3, 2),
new DataPoint(4, 6)
});
graph.addSeries(series);
return rootView;
}
3 回答
我通过添加Graphview.3.0.0 jar解决了这个问题 . 最初我正在使用Graphview.4.2.1所以同样的错误即将到来,但是当我添加较低版本时,一切都运行良好 .
我已经解决了这个错误 . 我刚刚更改了依赖项编译'com.jjoe64:graphview:4.2.2'以在build.gradle中编译'com.jjoe64:graphview:4.0.1' .
当前版本是4.2.1所以您应该将其更改为
compile 'com.jjoe64:graphview:4.2.1'