I am using graphview library in my android application to plot real time data coming from a sensor. I already have the graph, but I want to display the current value plotted in the graph also in a textview.
Here is the code I used for plotting the data in the graphview. Here, as an example, I generate and simulate 100 random values. But it's the same principle. And those random values shall be displayed in the same time they are added (appendData()) in the graph.
@Override
protected void onResume() {
super.onResume();
// we're going to simulate real time with thread that append data to the graph
new Thread(new Runnable() {
@Override
public void run() {
// we add 100 new entries
for (int i = 0; i < 100; i++) {
runOnUiThread(new Runnable() {
@Override
public void run() {
addEntry();
}
});
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
}).start();
}
private void addEntry() {
series.appendData(new DataPoint(lastX++, RANDOM.nextDouble() * 100d), true, 100);
}
Or is there another way than using a textview element?
Thanks in Advance!