Segment 1
Android Mini-game----Sudoku (one)
Rule: In 9x9 's chessboard, 9 squares in each row and column contain numbers 1 to 9, not duplicates,
Each of the 9 squares surrounded by a black thick solid line contains numbers 1 to 9, which are not duplicated.
Since the board is involved, there is no drawing, we know that the work of drawing in Android is done by the UI thread,
Generally refers to the main thread, while the Android system set UI drawing thread for more than 5 seconds will be reported abnormal, so generally in
The data is evaluated in the child thread, and then the message is sent to the UI thread to update the interface.
In Java we can draw by view, and by default, the view is very lightweight. Also on Android
We can also use view to draw, as long as we let our own class inherit view, overriding the OnDraw () method
, and then, in the activity, new an instance of the view class that you write yourself, and instantiate it and set it in Setcontentview ().
For a small game, its calculation is also lightweight, more than 5s is basically impossible, so directly in the UI thread to update the interface
There is no big problem, but here we try to use a drawing class provided by Android for drawing operations.
Is Surfaceview, This class inherits from view.
Android allows us to draw in Surfaceview, cache everything we draw on surface, and then on the main line range
Render to the screen. Such as:
OK, here we go, next we use Surfaceview to draw a Sudoku board.
Android Mini-game----Sudoku (one)