gpt4 book ai didi

java - StartTimePicker 设置时间(android)

转载 作者:行者123 更新时间:2023-12-01 11:28:37 24 4
gpt4 key购买 nike

抱歉我的英语不好。我想要如果单击 textView 打开对话框并设置时间(24 小时),但我无法获取值。 Log.e 不输出任何内容

time.setOnClickListener(new OnClickListener() {
@SuppressLint("NewApi") @Override
public void onClick(View v) {
DialogFragment dialogFragment = new StartTimePicker();
dialogFragment.show(getFragmentManager(), "start_t_picker");
}
});

//code
@SuppressLint("NewApi")
class StartTimePicker extends DialogFragment implements OnTimeSetListener{

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
TimePickerDialog dialog = new TimePickerDialog(Send.this, null, hour, min, true);

return dialog;
}


@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

Log.e("time is", String.valueOf(hourOfDay) + ":" + String.valueOf(minute));

}
}

最佳答案

像这样更改你的 onCreateDialog() 方法

            @Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
TimePickerDialog dialog = new TimePickerDialog(Send.this, this, hour, min, true);

return dialog;
}

关于java - StartTimePicker 设置时间(android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30617332/

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