Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old November 26th, 2011, 09:41 PM   #1 (permalink)
New Member
 
mineko's Avatar
 
Join Date: Nov 2011
Location: philippines
Posts: 7
 
Device(s): android 3.2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Android Dev: CountDown Timer

CountDown Timer with 10 minutes in initialization. How would I do that? Sorry I am noob of android development XD


This is my code:

public void onCreate(Bundle cute) {
super.onCreate(cute);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.main);

// If(updateTime()== TRUE)
updateTime();

handler.removeCallbacks(updateTimeTask);
handler.postDelayed(updateTimeTask, 1000);

Button exit =(Button) findViewById(R.id.exit);
exit.setOnClickListener(mExitListener);

Button reset =(Button) findViewById(R.id.reset);
reset.setOnClickListener(mResetListener);

PScore = (TextView)this.findViewById(R.id.pscore); //Period Score
PScore.setOnClickListener(pscoreClickListener);



}//end of cuteness


private OnClickListener pscoreClickListener = new OnClickListener() {
public void onClick(View v) {
//DO INCREASE after timer became 00:00
}};

private OnClickListener mResetListener = new OnClickListener() {
public void onClick(View v) {
onStop(); }; };

private OnClickListener mExitListener = new OnClickListener() {
public void onClick(View v) {
onDestroy(); }; };

protected void onReset() {
super.onDestroy();
//do stuff
}//onReset


private void updateTime() {
//long start = 0;
final TextView time = (TextView) findViewById(R.id.time);
//while(){

final Date currentTime1 = new Date( 15000);
final SimpleDateFormat formatterTime = new SimpleDateFormat( "mm:ss" );
time.setText( formatterTime.format(currentTime1) );

//start++;
//}//while
}

private Runnable updateTimeTask = new Runnable() {
public void run() {
updateTime();
handler.postDelayed(this, 1000);
}
};


@Override
protected void onDestroy() {
super.onDestroy();
System.exit(0);
}//onDestroy

@Override
protected void onResume() {
super.onResume();
handler.removeCallbacks(updateTimeTask);
handler.postDelayed(updateTimeTask, 1000);
}//onResume

@Override
protected void onPause() {
super.onPause();
//do stuff
}//onStop

@Override
protected void onStop() {
super.onStop();
handler.removeCallbacks(updateTimeTask);
}//onStop

}//end

Any help would be appreciated. THANKS!!

mineko is offline  
Reply With Quote
Sponsors
Reply

Bookmarks

Tags
android 3.2, java


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:50 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo