I am creating sound meter app in android I want to show values in line graph on real time anyone please tell me how I can do it?
问问题
2947 次
3 回答
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/
于 2014-04-24T11:18:16.867 回答
0
使用 AChartEngine 时,您只需将新值添加到系列并调用mChartView.repaint()
,以便使用新更新刷新图表。
于 2014-04-29T11:50:23.900 回答
0
在 onCreate(...) 中:
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 将自动滚动以在图表上显示最新数据。
于 2014-05-23T14:18:16.017 回答