Update android Textview continuously

前端 未结 4 1049
执笔经年
执笔经年 2021-01-22 12:27

I am working on an Android Application which have an one activity class and service class. In service, Continuous bulk data (1090 by

4条回答
  •  不思量自难忘°
    2021-01-22 12:55

    You can use Timer for Continously updating your textview.

    Set value in preferences every time when your service is running with the latest value.

    Now in Timer get that value from preferences and update your TextView with that value.

    Here is some code :

    class UpdateTimeTask extends TimerTask {
       public void run() {
    
       textview.setText("updated value");
       }
    }
    

    Set in onCreate ();

        Timer timer = new Timer();
        UpdateTimeTask  UpdateTimeTask = new UpdateTimeTask ();
        timer.schedule(UpdateTimeTask, 1000);
    

提交回复
热议问题