Closed christianCallelero closed 7 years ago
In this case use the native Android date picker :)
https://developer.android.com/guide/topics/ui/controls/pickers.html
Yeah its possible but I want to keep the design consistent to all my datepicker. Anyway I was able to clone the project and create an option for single date. closing this thread now.
@christianCallelero Hi, can you share the single date selection option you implemented?
@christianCallelero Hi, can you share the single date selection option you implemented?
maybe it's late, but anyway: you could just subclass the datepicker, and override #onViewCreated. use findViewById(android.R.id.tabs) to get "tabs" layout at hands and make it's visibility = GONE, so it is not displayed anymore. works with config change/screen rotation, because when view recreated - tabs are "GONE" again. the ondatechange listener stays the same, except you do not use "end" dates, since user intacts with the first tab only.
probably you need to recreate static constructors too (#newInstance methods)
internal class OnlyDatePickerDialog : com.borax12.materialdaterangepicker.date.DatePickerDialog() {
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// hide tabs heading so user cant see it
view?.findViewById<TabWidget>(android.R.id.tabs)?.let{
it.visibility = View.GONE
}
}
// static constructors are not inherited in kotlin, so recreate them
companion object {
fun newInstance(
callBack: OnDateSetListener, year: Int,
monthOfYear: Int,
dayOfMonth: Int
): OnlyDatePickerDialog {
val ret = OnlyDatePickerDialog()
ret.initialize(callBack, year, monthOfYear, dayOfMonth)
return ret
}
fun newInstance(
callBack: OnDateSetListener, year: Int,
monthOfYear: Int,
dayOfMonth: Int,
yearEnd: Int,
montOfYearEnd: Int,
dayOfMonthEnd: Int
): OnlyDatePickerDialog {
val ret = OnlyDatePickerDialog()
ret.initialize(callBack, year, monthOfYear, dayOfMonth, yearEnd, montOfYearEnd, dayOfMonthEnd)
return ret
}
}
}
`
Hi I would like to add a feature wherein we can use this library to somewhat disable the two tabs (From,To). So we can use it for just getting a single date. However I'm new to library cloning so can anyone help me with this? I know how to clone but my idea for adding this as a module is limited. Thanks