0

截屏

我想更改右上角的文本按钮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
    }
}
4

1 回答 1

1

尝试在 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>
于 2021-08-31T09:27:57.260 回答