Why isn't view.invalidate immediately redrawing the screen in my android game

前端 未结 4 2004
抹茶落季
抹茶落季 2020-12-08 16:25

I am trying to make an android game.

I have a game class that extends activity and handles all the user input. Then I have a missionView class that extends view and

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 17:18

    I've faced with the same problem in my application.

    In my case I was trying to call invalidate() from the [doInBackground()][1] method of the [AsyncTask][2].

    The problem was solved by moving invalidate() to [onProgressUpdate()][3] method of AsyncTask. I.e. you cannot update UI from the doInBackground() method of AsyncTask. It is mentioned in Android docs, but it is so easy to forget about it... so, don't forget to check it.

提交回复
热议问题