We are using 2 edittext, one to enter hours and one to enter Minutes.
int CountM;
int CountT;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Mylabel = (EditText)findViewById(R.id.editText1);
Hours = (EditText)findViewById(R.id.Timer);
Minuttes = (EditText)findViewById(R.id.Minutter);
void StartTimer()
{
int TotalT = ((CountT*60*60)+(CountM*60)*1000);
mTextField = (TextView) findViewById(R.id.TimerTextView);
CountDownTimer aCounter = new CountDownTimer(TotalT, 1000)
{
public void onTick(long millisUntilFinished)
{
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish()
{
mTextField.setText("seconds remaining: " + CountM + CountT);
}
};
aCounter.start();
}
As you can see we need to collect data from our Edittext from Hours into CountT and Minutes into CountM and spit those results out, get it down to seconds so we can set it to do a task 5 hours later.
We have tried with strings and converting them into Ints.
Any suggestions?
Assuming you have a
Buttonin your layout, on clicking which, you need to start the timer, the code for the same would be:A suggestion: While you are still learning, it would be a good idea to understand and follow the Java Code Conventions