Androidplot error: Cannot resolve getGraphWidget and other method
Androidplot error: Cannot resolve getGraphWidget and other method
我目前正在开发 Android 大学阶段的应用程序。
此应用程序必须使用来自某些压力传感器的数据绘制图表,为了绘制此图表,我正在使用 Android 绘图库。
我正在按照 Andrloidplot 文档上的 this 示例创建动态 XYPlot,并且我在项目依赖项中导入了 androidplot-core:1.1.0。
在代码编辑器中,每次调用 getGraphWidget()
、setRangeValueFormat()
以及尝试访问 XYStepMode
字段时,我都会收到 "Cannot resolve .... method" 错误。
我已经在互联网和 Androidplot 文档上搜索过这个问题,但我没有找到任何有用的东西。
我认为这是由我遗漏的一些进口产生的,但我不知道我忘记了什么。
有人已经处理过这个问题并解决了吗?
这是我的 class 中第一次出现错误的部分,它在最后一行:
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.androidplot.Plot;
import com.androidplot.util.PixelUtils;
import com.androidplot.xy.XYSeries;
import com.androidplot.xy.*;
import java.text.DecimalFormat;
import java.util.Observable;
import java.util.Observer;
/**
* Created by marco on 07/09/16.
*/
public class GraphicChart extends Fragment {
private XYPlot dynamicPlot;
private MyPlotUpdater plotUpdater;
SampleDynamicXYDatasource data;
private Thread myThread;
public GraphicChart(){}
// redraws a plot whenever an update is received:
private class MyPlotUpdater implements Observer {
Plot plot;
public MyPlotUpdater(Plot plot) {
this.plot = plot;
}
@Override
public void update(Observable o, Object arg) {
plot.redraw();
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.graphic_chart_fragment, container, false);
// get handles to our View defined in layout.xml:
dynamicPlot = (XYPlot)getActivity().findViewById(R.id.dynamic_plot);
plotUpdater = new MyPlotUpdater(dynamicPlot);
// only display whole numbers in domain labels
dynamicPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0")); //FIRST ERROR ON THIS LINE
我终于解决了它,我比较了我链接的网站和 gitHub 上的来源。
这里是我所做的更改:
行
//只在域标签中显示整数
dynamicPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0"));
现在
// only display whole numbers in domain labels
dynamicPlot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.BOTTOM).
setFormat(new DecimalFormat("0"));
XYStepMode
现在只有 StepMode
现在调用dynamicPlot.setRangeValueFormat(new DecimalFormat("###.#"));
就是这样完成的
dynamicPlot.getGraph().getLineLabelStyle(
XYGraphWidget.Edge.LEFT).setFormat(new DecimalFormat("###.#"));
我目前正在开发 Android 大学阶段的应用程序。 此应用程序必须使用来自某些压力传感器的数据绘制图表,为了绘制此图表,我正在使用 Android 绘图库。
我正在按照 Andrloidplot 文档上的 this 示例创建动态 XYPlot,并且我在项目依赖项中导入了 androidplot-core:1.1.0。
在代码编辑器中,每次调用 getGraphWidget()
、setRangeValueFormat()
以及尝试访问 XYStepMode
字段时,我都会收到 "Cannot resolve .... method" 错误。
我已经在互联网和 Androidplot 文档上搜索过这个问题,但我没有找到任何有用的东西。 我认为这是由我遗漏的一些进口产生的,但我不知道我忘记了什么。
有人已经处理过这个问题并解决了吗?
这是我的 class 中第一次出现错误的部分,它在最后一行:
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.androidplot.Plot;
import com.androidplot.util.PixelUtils;
import com.androidplot.xy.XYSeries;
import com.androidplot.xy.*;
import java.text.DecimalFormat;
import java.util.Observable;
import java.util.Observer;
/**
* Created by marco on 07/09/16.
*/
public class GraphicChart extends Fragment {
private XYPlot dynamicPlot;
private MyPlotUpdater plotUpdater;
SampleDynamicXYDatasource data;
private Thread myThread;
public GraphicChart(){}
// redraws a plot whenever an update is received:
private class MyPlotUpdater implements Observer {
Plot plot;
public MyPlotUpdater(Plot plot) {
this.plot = plot;
}
@Override
public void update(Observable o, Object arg) {
plot.redraw();
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.graphic_chart_fragment, container, false);
// get handles to our View defined in layout.xml:
dynamicPlot = (XYPlot)getActivity().findViewById(R.id.dynamic_plot);
plotUpdater = new MyPlotUpdater(dynamicPlot);
// only display whole numbers in domain labels
dynamicPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0")); //FIRST ERROR ON THIS LINE
我终于解决了它,我比较了我链接的网站和 gitHub 上的来源。
这里是我所做的更改:
行
//只在域标签中显示整数 dynamicPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0"));
现在
// only display whole numbers in domain labels
dynamicPlot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.BOTTOM).
setFormat(new DecimalFormat("0"));
XYStepMode
现在只有StepMode
现在调用
dynamicPlot.setRangeValueFormat(new DecimalFormat("###.#"));
就是这样完成的dynamicPlot.getGraph().getLineLabelStyle(
XYGraphWidget.Edge.LEFT).setFormat(new DecimalFormat("###.#"));