在 MaterialDatePicker dateRangePicker() 中更改右上角的文本按钮
Change text button in top right in MaterialDatePicker dateRangePicker()
我想更改右上角的文本按钮 SAVE。
我用过这个库
com.google.android.material:material:1.4.0
val dateRangePicker = MaterialDatePicker.Builder.dateRangePicker()
.setTitleText("Select Date")
.setTheme(R.style.Widget_AppTheme_MaterialDatePicker)
.build()
dateRangePicker.show(childFragmentManager, "date_range_picker")
dateRangePicker.addOnPositiveButtonClickListener {
val start = it.first
val last = it.second
if (start != null && last != null){
val dateRange = "${globalHelper?.convertLongToString(start)} - ${globalHelper?.convertLongToString(last)}"
binding.tvDateRange.text = dateRange
}
}
尝试在 strings.xml
中使用您自己的文本添加以下行
<string name="mtrl_picker_save" description="Button text to indicate that the widget will save the user's selection [CHAR_LIMIT=16]">.....</string>
<string name="mtrl_picker_cancel" description="Button text to indicate that the widget will ignore the user's selection [CHAR_LIMIT=16]" translatable="false">...</string>
我想更改右上角的文本按钮 SAVE。
我用过这个库
com.google.android.material:material:1.4.0
val dateRangePicker = MaterialDatePicker.Builder.dateRangePicker()
.setTitleText("Select Date")
.setTheme(R.style.Widget_AppTheme_MaterialDatePicker)
.build()
dateRangePicker.show(childFragmentManager, "date_range_picker")
dateRangePicker.addOnPositiveButtonClickListener {
val start = it.first
val last = it.second
if (start != null && last != null){
val dateRange = "${globalHelper?.convertLongToString(start)} - ${globalHelper?.convertLongToString(last)}"
binding.tvDateRange.text = dateRange
}
}
尝试在 strings.xml
中使用您自己的文本添加以下行<string name="mtrl_picker_save" description="Button text to indicate that the widget will save the user's selection [CHAR_LIMIT=16]">.....</string>
<string name="mtrl_picker_cancel" description="Button text to indicate that the widget will ignore the user's selection [CHAR_LIMIT=16]" translatable="false">...</string>