What is recommended way to update android ui from a -continuous- background thread?

后端 未结 2 1179

I\'ve read well enough on the subject to get well and thoroughly confused. I\'m doing a workout tracker app such as RunKeeper, which tracks how long and how far the user has

2条回答
  •  被撕碎了的回忆
    2020-12-20 09:12

    Use runOnUiThread().

    Define a Runnable:

    private Runnable mRunnable = new Runnable() {
        @Override
        public void run() {
            mTextViewOne.setText("10 miles!");
            mTextViewTwo.setText("40 minutes!");
        }
    };
    

    Inside your continuous thread:

    runOnUiThread(mRunnable);
    

提交回复
热议问题