I made TimePickerDialog
, but I can not get it to call the current time at the beginning, it always calls 00h00. I wonder where I'm going wrong.
Code:
private void chamarTimePickerDialog() {
TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hora, int minuto) {
Toast.makeText(getActivity(), hora+ ":" + minuto, Toast.LENGTH_SHORT).show();
capHora.setText(hora+ ":" +minuto);
Calendar calNow = Calendar.getInstance();
calNow.setTimeInMillis(System.currentTimeMillis());
calNow.set(Calendar.HOUR_OF_DAY, hora);
calNow.set(Calendar.MINUTE, minuto);
}
};
TimePickerDialog dialog = new TimePickerDialog(getActivity(), mTimeSetListener,0, 0, true);
dialog.show();
}