Ok, I have been reading an writing as I go along but I have gotten myself into a complete mess. My short code is below, I need help filling in the gaps. The problem is that just looking at the Google documentation simply details properties and methods of classes, functions, objects etc but doesn't (IMO) clearly explain them. How can I tackle the code below?
I have been Google'ing my behind off, and I have read so many different tutorials about threads, clocks, handlers, I've lost my self, can someone explain how to do this (and if possible why they have made the suggestion they did)?
Code:
package com.my.firstapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class firstapp extends Activity {
Button start;
Button stop;
TextView duration;
Integer intMillis;
Integer intSeconds;
Integer intMinutes;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
start= (Button)this.findViewById(R.id.start);
stop= (Button)this.findViewById(R.id.stop);
duration = (TextView)this.findViewById(R.id.txtDuration);
start.setOnClickListener(new Button.OnClickListener() {public void onClick(View v) {start();} });
stop.setOnClickListener(new Button.OnClickListener() {public void onClick(View v) {stop();} });
intMillis= 0;
intSeconds= 0;
intMinutes= 0;
}
public void start() {
//HERE I WANT TO START A NEW THREAD WHICH WILL DO SOMETHING EVERY 200ms
//UNTIL I PRESS THE STOP BUTTON
}
public voide stop() {
//STOP THE 2ND THREAD
}
}
I have been Google'ing my behind off, and I have read so many different tutorials about threads, clocks, handlers, I've lost my self, can someone explain how to do this (and if possible why they have made the suggestion they did)?