GraphView is not updated when new data is added

前端 未结 3 1567
傲寒
傲寒 2021-01-16 23:18

I have a GraphView that is not updated when new data is added, it changes the Y value to accommodate for the new data, but it doesn\'t draw them, here is the co

3条回答
  •  长情又很酷
    2021-01-17 00:08

    Wow actually works now, took me quite a while to notice I need a Handler... Thanks, heres my code for other noobs like me:

    refreshButton.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                graphHandler.post(
                graphRunnable = new Runnable()
                {
                    public void run() 
                    {
                        sensorSeries.appendData(new GraphViewData(xgraph, dataAcx), false, 20);
                        graphView.redrawAll();
                        myLabel.setText(""+dataAcx+" "+xgraph);
                        xgraph++;
                        dataAcx++;
                    }
                }
                );
            }
        });
    

提交回复
热议问题