android - Trouble getting time out of TimePicker -


i trying set time form time picker reason , not happening.

i using getcurrenthour , getcurrentminute() don't seem doing job.i have tried clearfocus() did not make difference.

i trying time on button click. have attached relevant code below , let me know if need 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(); // did not              cal.set(               time_picker.getcurrenthour(),                time_picker.getcurrentminute(),                00);              toast.maketext(getapplicationcontext(),                    "set time: "+cal.gettime(),                    toast.length_long).show(); // returning current time                                                   // gets initialised               setalarm(cal);         }      }); 

my question : how the time form timepicker?

thanks taking time read , can give.

cal.set(time_picker.getcurrenthour(), time_picker.getcurrentminute(), 00); 

calls overloaded method used set year, month , day.

use double argument set used set specified field of calendar.

cal.set (calendar.hour_of_day, time_picker.getcurrenthour()); cal.set (calendar.minute, time_picker.getcurrentminute()); cal.set (calendar.second, 0); cal.set (calendar.millisecond,0); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -