我在android中创建声音计量器应用程序我希望在线图中实时显示值,有人请告诉我如何做到这一点?
答案 0 :(得分:0)
对于时间操作,请参阅android.text.format.Time http://developer.android.com/reference/android/text/format/Time.html
这是来自那里的官方示例代码:
Time time = new Time();
time.set(4, 10, 2007); // set the date to Nov 4, 2007, 12am
time.normalize(false); // this sets isDst = 1
time.monthDay += 1; // changes the date to Nov 5, 2007, 12am
millis = time.toMillis(false); // millis is Nov 4, 2007, 11pm
millis = time.toMillis(true); // millis is Nov 5, 2007, 12am
现在显示图表没有现成的类,所以你必须自己通过覆盖Draw()
类的View
函数来绘制它,或者搜索库来执行此操作,例如:http://android-graphview.org/
答案 1 :(得分:0)
使用AChartEngine时,您只需要将新值添加到系列中并调用mChartView.repaint()
,以便使用新更新刷新图表。
答案 2 :(得分:0)
:
GraphView graphView = new LineGraphView(this, "Amplitude");
graphView.setScrollable(true);
graphView.setViewPort(0, 30); // the x range you want to show without scrolling
GraphViewSeries graphSeries = new GraphViewSeries(new GraphViewDataInterface[0]);
graphView.addSeries(graphSeries);
setContentView(graphView);
//or add your graphView to the Activity's view as appropriate
然后,当您获得新值时:
graphSeries.appendData(new GraphView.GraphViewData(xValue, yValue), true, 300);
//where 300 is the maximum number of values to keep
右边会出现新值,GraphView会自动滚动显示图表上的最新数据。