public View onCreateView(LayoutInflater inflater,ViewGroup容器, 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;
}
答案 0 :(得分:0)
我已经解决了这个错误。我刚刚更改了依赖项compile&#39; com.jjoe64:graphview:4.2.2&#39;编译&#39; com.jjoe64:graphview:4.0.1&#39;在build.gradle中。
答案 1 :(得分:0)
当前版本为4.2.1,因此您应将其更改为
Allocation = y.Allocation / 100D
答案 2 :(得分:0)
我已经通过添加Graphview.3.0.0 jar解决了这个问题。 最初我正在使用Graphview.4.2.1,所以同样的错误即将到来,但是当我添加较低版本时,一切都运行良好。