我只需要在搜索的时间选择器中显示 https://www.example.com/foo/bar
https://www.example.com/baz
https://www.example.net/quack
https://www.example.info/foo/bar
,但找不到任何内容,有人知道如何实现吗?
答案 0 :(得分:5)
Android时间选择器不提供setInterval()
所需的MaterialDateTimepicker
方法
implementation 'com.wdullaer:materialdatetimepicker:3.6.3'
其最新版本与我的某些库冲突,这就是为什么我使用3.6.3
也有人使用NumberPicker
来完成它对我不起作用
Calendar now = Calendar.getInstance();
TimePickerDialog timePickerDialog = TimePickerDialog.newInstance(mTimePickerListener,
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE),
false
);
timePickerDialog.setThemeDark(false);
timePickerDialog.setTitle("TimePicker Title");
timePickerDialog.setTimeInterval(1, 15, 30); // 15 Minutes Interval
//timePickerDialog.setTimeInterval(1, 30, 60); // 30 Minutes Interval
timePickerDialog.setAccentColor(Color.parseColor("#9C27B0"));
timePickerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
Log.d("TimePicker", "Dialog was cancelled");
}
});
timePickerDialog.show(getFragmentManager(), "Timepickerdialog");
}
private TimePickerDialog.OnTimeSetListener mTimePickerListener = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
}
};
答案 1 :(得分:0)
您可以通过创建可绘制的自定义圆形形状来创建自定义时间选择器,并将其作为框架布局的背景,并获取时间值,以监听textviews的click事件。
代码: bg_circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke android:width="2dp"/>
</shape>
layout_picker.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/bg_circle"
android:padding="4dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:layout_gravity="center_horizontal|top"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="15"
android:layout_gravity="center_vertical|end"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30"
android:layout_gravity="center_horizontal|bottom"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="45"
android:layout_gravity="center_vertical|start"
/>
</FrameLayout>
希望有帮助