我正在试验一个实时的情节,但它不是实时显示。1秒后,即睡眠10次所需的时间,它只是完整地显示绘图。
为了 onCreate
```
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/* Buttons */
graph = (GraphView) findViewById(R.id.graph);
}
当我点击按钮
public void runRealTime(View v){
graph.removeAllSeries();
/**------ Set x bounds ------ */
Viewport vp = graph.getViewport();
vp.setXAxisBoundsManual(true);
vp.setMinX(-5);
vp.setMaxX(20);
/**------ Init ------ */
LineGraphSeries<DataPoint> series;
series = new LineGraphSeries<>();
series.setColor(Color.BLACK);
graph.addSeries(series);
/**------ Real Time plot ------ */
for (int i = 0; i < 10; i++) {
series.appendData(new DataPoint(i, i), true, 40);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
暂无答案!
目前还没有任何答案,快来回答吧!