Saturday 15 March 2014

java - How to implement handler in another class? -


I have three buttons in my app and when a button is clicked, call it a thread to start this thing I want to be able to input some of the sources in the form of input syntax and do some work, it is returned to the UI thread where I can display it or to display an object to put it in OpenGLL. Can i I have read on handle and I am not sure that I understand them completely and if anyone knows how to make their own handler code, apart from this, I have read on async and I do not think it will be done by my app Will give. (Let me know if this is the private app, if it does not match my app) My question is how do I get information from UI editor, when entry is pressed in line DrawingUtils is used for the thread in the class, then it UI returns to display or input athlete in an open GL program?

Here is the main activity class:

  OnClickListener {editText cl; Text view information; Enter the button; Button line; Button arc; Line callline = new drawing .uillline (); CallEnter = Enter new drawing. Submit it (); Arc Callar = new drawing utility. ARC (); @ Override protected void saved create (bundled Instansstet) {Suprknkret (saved Instensstet); SetContentView (R.layout.activity_main); Info = (TextView) findViewById (R.id.info); Enter = (button) findViewById (R.id.enter); Find Line = (Button) VVBIID (R. Line); Arc = (buttons) Find VVBID (RIDCr); Handler UI Handler = New Handler () {@ Override Public Wide Handmade (Message msg) {Bundle Bundle = msg.getData (); String string = bundle .get string ("mike"); }}; } @ Override Public Zero (see V) {// TODO Auto generated method stub switch (v.getId ()) {case R.id.enter: callEnter.start (); break; Case R.id.line: callLine.start (); break; Case R.id.arc: callArc.start (); break; }}; }   

Here is the DrawingUtils class:

  Public class DrawingUtils {MainActivity handle = new MainActivity (); // Thread Classes Enter the public Static Class for the button Extensions Thread {Thread Enter = New Thread () {Public Zero Run () {}}; Expansion of public static class line thread {thread line = new thread () {public zero run () {}}; } Expands public static class arc threads {thread arc = new thread () {public void run () {}}; }}}}    

  increases public MyActivity activity {@Override Protected void onCreate {bundle saved instance} {// .... handler myHandler = new handler () {@ Override public wide messages (message message) {doCoolStuffWhenMessageReceived (); }} MySecondClass secondClass = new MySecondClass (myHandler); // ....}} public class MySecondClass {Private handler; Public MySecondClass (handler handler) {this.handler = handler; } Private Zero Some MethodToCallActivity () {handler.sendEmptyMessage (0); }}    

No comments:

Post a Comment