gpt4 book ai didi

android - 微调器模式下的 TimePickerDialog

转载 作者:搜寻专家 更新时间:2023-11-01 09:23:17 27 4
gpt4 key购买 nike

在我的项目中,我使用 TimepickerDialogTextView 中显示时间。我的 Timepickerdialog 显示为时钟,但我希望它显示为微调器。我该怎么做?

最佳答案

使用此代码显示时间选择器作为微调器

    public void showCustomTimePicker()
{

final Calendar myCalender = Calendar.getInstance();
int hour = myCalender.get(Calendar.HOUR_OF_DAY);
int minute = myCalender.get(Calendar.MINUTE);


TimePickerDialog.OnTimeSetListener myTimeListener = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
if (view.isShown()) {
myCalender.set(Calendar.HOUR_OF_DAY, hourOfDay);
myCalender.set(Calendar.MINUTE, minute);

}
}
};
TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), android.R.style.Theme_Holo_Light_Dialog_NoActionBar, myTimeListener, hour, minute, true);
timePickerDialog.setTitle("Choose hour:");
timePickerDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
timePickerDialog.show();
}

关于android - 微调器模式下的 TimePickerDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52775481/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com