本文整理了Java中android.widget.TimePicker.getCurrentHour()
方法的一些代码示例,展示了TimePicker.getCurrentHour()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimePicker.getCurrentHour()
方法的具体详情如下:
包路径:android.widget.TimePicker
类名称:TimePicker
方法名:getCurrentHour
暂无
代码示例来源:origin: ankidroid/Anki-Android
@Override
@SuppressWarnings("deprecation")
public int getHour(TimePicker picker) { return picker.getCurrentHour(); }
@Override
代码示例来源:origin: square/assertj-android
public TimePickerAssert hasCurrentHour(Integer hour) {
isNotNull();
Integer actualHour = actual.getCurrentHour();
assertThat(actualHour) //
.overridingErrorMessage("Expected current hour <%s> but was <%s>.", hour, actualHour) //
.isEqualTo(hour);
return this;
}
代码示例来源:origin: stackoverflow.com
final View dialogView = View.inflate(activity, R.layout.date_time_picker, null);
final AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
dialogView.findViewById(R.id.date_time_set).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DatePicker datePicker = (DatePicker) dialogView.findViewById(R.id.date_picker);
TimePicker timePicker = (TimePicker) dialogView.findViewById(R.id.time_picker);
Calendar calendar = new GregorianCalendar(datePicker.getYear(),
datePicker.getMonth(),
datePicker.getDayOfMonth(),
timePicker.getCurrentHour(),
timePicker.getCurrentMinute());
time = calendar.getTimeInMillis();
alertDialog.dismiss();
}});
alertDialog.setView(dialogView);
alertDialog.show();
代码示例来源:origin: stackoverflow.com
calendar.set(Calendar.HOUR_OF_DAY, picker.getCurrentHour());
calendar.set(Calendar.MINUTE, picker.getCurrentMinute());
代码示例来源:origin: stackoverflow.com
lastHour=picker.getCurrentHour();
lastMinute=picker.getCurrentMinute();
代码示例来源:origin: stackoverflow.com
case BUTTON_POSITIVE:
if (mTimeSetListener != null) {
mTimeSetListener.onTimeSet(mTimePicker, mTimePicker.getCurrentHour(),
mTimePicker.getCurrentMinute() * TIME_PICKER_INTERVAL);
代码示例来源:origin: facebook/facebook-android-sdk
} else if (view instanceof TimePicker) {
TimePicker picker = (TimePicker) view;
int h = picker.getCurrentHour();
int m = picker.getCurrentMinute();
textObj = String.format("%02d:%02d", h, m);
代码示例来源:origin: stackoverflow.com
TimePicker t = new TimePicker(this);
String formattedTime = "";
int hour = t.getCurrentHour();
String sHour = "00";
if(hour < 10){
sHour = "0"+hour;
} else {
sHour = String.valueOf(hour);
}
int minute = t.getCurrentMinute();
String sMinute = "00";
if(minute < 10){
sMinute = "0"+minute;
} else {
sMinute = String.valueOf(minute);
}
formattedTime = sHour+":"+sMinute+":"+"00"; // Sorry you can't get seconds from a TimePicker
代码示例来源:origin: stackoverflow.com
final TimePicker timePicker = new TimePicker(this);
timePicker.setIs24HourView(true);
timePicker.setCurrentHour(20);
timePicker.setCurrentMinute(15);
new AlertDialog.Builder(this)
.setTitle("Test")
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.d("Picker", timePicker.getCurrentHour() + ":"
+ timePicker.getCurrentMinute());
}
})
.setNegativeButton(android.R.string.cancel,
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
Log.d("Picker", "Cancelled!");
}
}).setView(timePicker).show();
代码示例来源:origin: stackoverflow.com
if (mCallback != null && mTimePicker!=null) {
mTimePicker.clearFocus();
mCallback.onTimeSet(mTimePicker, mTimePicker.getCurrentHour(),
mTimePicker.getCurrentMinute()*increment);
代码示例来源:origin: stackoverflow.com
final DatePicker dp = (DatePicker) findViewById(R.id.datePicker);
final TimePicker tp = (TimePicker) findViewById(R.id.timePicker);
btnSet.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String strDateTime = dp.getYear() + "-" + (dp.getMonth() + 1) + "-" + dp.getDayOfMonth() + " "+ tp.getCurrentHour() + ":" + tp.getCurrentMinute();
Toast.makeText(TimeDate.this, "User selected " + strDateTime + "Time", Toast.LENGTH_LONG).show(); //Generate a toast only if you want
finish(); // If you want to continue on that TimeDateActivity
// If you want to go to new activity that code you can also write here
}});
代码示例来源:origin: SecUSo/privacy-friendly-pedometer
protected int getHour(TimePicker timePicker) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return timePicker.getHour();
} else {
return timePicker.getCurrentHour();
}
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public TimePickerAssert hasCurrentHour(Integer hour) {
isNotNull();
Integer actualHour = actual.getCurrentHour();
assertThat(actualHour) //
.overridingErrorMessage("Expected current hour <%s> but was <%s>.", hour, actualHour) //
.isEqualTo(hour);
return this;
}
代码示例来源:origin: renyuneyun/Easer
private static Calendar fromTimePicker(TimePicker timePicker) {
Calendar calendar = Calendar.getInstance();
if (Build.VERSION.SDK_INT >= 23) {
calendar.set(Calendar.HOUR_OF_DAY, timePicker.getHour());
calendar.set(Calendar.MINUTE, timePicker.getMinute());
} else {
calendar.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
calendar.set(Calendar.MINUTE, timePicker.getCurrentMinute());
}
return calendar;
}
代码示例来源:origin: renyuneyun/Easer
private static Calendar fromTimePicker(TimePicker timePicker) {
Calendar calendar = Calendar.getInstance();
if (Build.VERSION.SDK_INT >= 23) {
calendar.set(Calendar.HOUR_OF_DAY, timePicker.getHour());
calendar.set(Calendar.MINUTE, timePicker.getMinute());
} else {
calendar.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
calendar.set(Calendar.MINUTE, timePicker.getCurrentMinute());
}
return calendar;
}
代码示例来源:origin: termux/termux-api
@Override
String getResult() {
String result;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
result = String.format(Locale.getDefault(), "%02d:%02d", widgetView.getHour(), widgetView.getMinute());
} else {
result = String.format(Locale.getDefault(), "%02d:%02d", widgetView.getCurrentHour(), widgetView.getCurrentMinute());
}
return result;
}
代码示例来源:origin: mathisdt/trackworktime
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
lastHour = picker.getCurrentHour();
lastMinute = picker.getCurrentMinute();
String time = String.valueOf(lastHour) + ":" + String.valueOf(lastMinute);
if (callChangeListener(time)) {
persistString(time);
}
}
}
代码示例来源:origin: dsolonenko/financisto
private void setDialogResult(Dialog d, Calendar c) {
DatePicker dp = d.findViewById(R.id.date);
c.set(Calendar.YEAR, dp.getYear());
c.set(Calendar.MONTH, dp.getMonth());
c.set(Calendar.DAY_OF_MONTH, dp.getDayOfMonth());
TimePicker tp = d.findViewById(R.id.time);
c.set(Calendar.HOUR_OF_DAY, tp.getCurrentHour());
c.set(Calendar.MINUTE, tp.getCurrentMinute());
updateDate();
}
代码示例来源:origin: oliexdev/openScale
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
calendar.set(Calendar.HOUR_OF_DAY, picker.getCurrentHour());
calendar.set(Calendar.MINUTE, picker.getCurrentMinute());
setSummary(getSummary());
if (callChangeListener(calendar.getTimeInMillis())) {
persistLong(calendar.getTimeInMillis());
notifyChanged();
}
}
}
代码示例来源:origin: daliyan/MyKeep
private void setDateTime(){
if(mOnTimeSetListener!=null && mDatePicker!=null && mTimePicker!=null){
mOnTimeSetListener.onDateTimeSet(mDatePicker.getYear(),mDatePicker.getMonth(),mDatePicker.getDayOfMonth(),
mTimePicker.getCurrentHour(),mTimePicker.getCurrentMinute());
}
this.dismiss();
}
内容来源于网络,如有侵权,请联系作者删除!