Friday, 23 August 2013

Trouble getting time out of TimePicker

Trouble getting time out of TimePicker

I am trying to get the set time form a time picker from for some reason ,
it is not happening.
I am using getCurrentHour and getCurrentMinute() but they don't seem to be
doing the job.I have tried to clearFocus() but that did not make a
difference.
I am trying to get the time on a button click. I have attached the
relevant code below , let me know if you need to see anymore.
Button next_button = (Button) findViewById(R.id.next_button);
next_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
//Calendar current = Calendar.getInstance();
Calendar cal = Calendar.getInstance();
//time_picker = (TimePicker) findViewById(R.id.time);
// time_picker.clearFocus(); // this did not help
cal.set(
time_picker.getCurrentHour(),
time_picker.getCurrentMinute(),
00);
Toast.makeText(getApplicationContext(),
"set time: "+cal.getTime(),
Toast.LENGTH_LONG).show(); // this is returning the
current time
// that gets initialised
with
setAlarm(cal);
}
});
my question is : how do i get the the time form the TImePicker?
Thanks for taking the time to read this and for any help that you can give.

No comments:

Post a Comment