android - Can't get the hour and minute from TimePicker -
i take time gui control 'timepicker' , try set time on object type 'calendar' intent ( used serializable ).
on method 'public void donebtnclickevent(view view) ' exception on line '_calendar.set(calendar.hour, _timepicker.gethour());'
i don't understand did wrong , how solve problem.
public class settimeactivicy extends appcompatactivity { private timepicker _timepicker; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_set_time_activicy); _timepicker = (timepicker)findviewbyid(r.id.timepicker); _timepicker.setis24hourview(true); } public void donebtnclickevent(view view) { try { // exception !! => cant take hour , min int h = _timepicker.gethour(); int m = _timepicker.getminute(); } catch(exception e) { log.e("exception - error ", e.getmessage()); } }
}
solved ... use
int hour = _timepicker.getcurrenthour(); int minute = _timepicker.getcurrentminute();
the method
int h = _timepicker.gethour(); int m = _timepicker.getminute();
are not working
Comments
Post a Comment