Sunday, June 30, 2013

[android help] how to set current time running continuesly with hours ,minutes ,seconds to textview in android?


how to set current time running continuesly with hours ,minutes ,seconds to textview in android?


how to set the current time running continuously with hours ,minutes ,seconds to textview in android? - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















Actually by the time my Activity starts i should display current time in hours ,minutes,seconds(HH:mm:ss) in 24 hours format, and this time should run continuously as seconds need to change continuously gradually minutes and hours also. I kept a stop button in activity. once stop is clicked the time should stop and that stopped time need to be saved in a string .





























Try like this.. onClick of STOP Button



String currentTimeString = new SimpleDateFormat("HH:mm:ss").format(new Date());


Use this string in Toast or TextView or whatever depending on your requirement


To get Watch like display refer here























Try this code..



Date date =new Date();
DateFormat format = SimpleDateFormat.getTimeInstance
( SimpleDateFormat.MEDIUM, Locale.getDefault());

// set the text of component TextView with id 'message'
textView.setTextViewText(R.id.widget_textview,"Current Time "+ format.format(date));



















default






.

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...