


Private Counter void onCreate(Bundle savedInstanceState) Public void setCountListener(ICounterEvents listener)Ĭ(value) Īnd create a interface class: public interface ICounterEventsĪnd than in your main layout create a textview and a button,Īnd use this code in onCreate method in MainActivity: public class MainActivity extends Activity implements ICounterEvents, OnClickListener I dont think that it will be heavy just for few maths But also if it is heavy, it can be done without making the UI thread unresponsive, using thread for the calculations. blocking system-io-call to read data from socket.Ĭreate Counter class : public class Counter implements Runnable Hello, Lets suppose you have one EditText and one TextView, with ids in your xml: myedittext1 and mytextview2. public class Receiver implements Runnable

MyExecutor = Executors.newCachedThreadPool() Protected void onCreate(Bundle savedInstanceState) public class MainActivity extends Activity What is a simple but proper way to do so? I read something about ASyncTask, but did not understand how to implement it. This thread shall refresh a TextView-Element on the GUI when new data was read from the stream. I start a thread (Receiver), receiving data from a SocketStream. I'm using the Android SDK for the first time and my Java Skills are rather average.įrom my MainActivity - OnCreate() fct. I know there are already quite a number of discussions about this, but none of what I found could clear my confusion.
