Android Mini-game----Sudoku (one)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.