multithreading - Threading in Android. NO idea what to do. SUPER confused -
I've been using Java only for a few weeks, and I do not know what's going on.
I am creating a canvas, and I have pasted this code with a powerful, but it has a bunch of errors, which I am sure can only be because I do not know exactly How to Set Up Code The tutorial is for those who already know how to thread, and I'm lost. I do not know how to fix errors
i.e .::
postInvalidate () "is not a way" or something else, although it is built in an Android functions. .. with set dot draws and others.
I'm super confused and I do not know how to fix these errors
package com.example.routedrawingtest; Import Android.graphics. Canvas; Import android.view.SurfaceHolder; Class PanelTrade Expands Thread {Private SurfhillHoldServe Holder; Private drawingpanel_panel; Private boolean _run = false; Public panelread (Surffolder surfaceholder, drawing panel panel) {_surfaceHolder = surfaceHolder; _panel = panel; } Public Zero Setting (boolean run) {// Allow us to stop thread _run = run; } @ Override Public Wide Run () {Canvas C; While (_run) {// when setRunning (wrong) happens, _run c = null; // false and loop set to end, stopping the thread {c = _surfaceHolder.lockCanvas (null); Synchronize (_surfaceHolder) {postInvalidate (); }} Finally {if (c! = Null) {_surfaceHolder.unlockCanvasAndPost (c); }}}} Surface form of public zero (surface holder) {setWillNotDraw (wrong); // allows us to call on using invalid () Draw () _thread = new paneltrade (getHolder (), this); // Start the thread that is _thread.setRunning (true); // will call _thread.start (); // On Draw ()} Public Zero Surface Destroy (Surface Holder Holder) {try {_thread.setRunning (wrong); // thread to thread Tells to close (); // removes the thread from the meme} Hold (Interrupted Exception E) {}}
Post Evaluate () and Set WillNotDraw () Apply Normal View and View Your Code Comes to a Surface for Group-Based Graphics
If you are new and you do not know what you are doing , Then I recommend that you throw all the surface accessories. Learn how to design a layout based on the view and the group and type the code. It does not require any threading.
Start here:
Comments
Post a Comment