在新的MaterialDatePicker中更改按钮文本 [英] Change button text in new MaterialDatePicker
问题描述
我正在将日历组件迁移到新的材料库 MaterialDatePicker
,但是我在做一些简单的事情(如更改确认按钮文本的名称)时遇到了问题
I am migrating the calendar components to the new Materials library, MaterialDatePicker
, however I am having problems in doing something as simple as changing the name of the confirm button texts
以前足够
datePickerDialog.setButton(DatePickerDialog.BUTTON_POSITIVE, getString(R.string.save), datePickerDialog)
但是现在我找不到任何公共方法
But now I can't find any public method
val picker = Builder.datePicker()
picker.addOnPositiveButtonClickListener { selection: Long ->
saveListPosition()
accountDetailsPresenter.editDate(selection, transaction, product, "")
}
picker.show(childFragmentManager, picker.toString())
推荐答案
当前( 1.1.0-beta02
和 1.2.0-alpha02
)您无法执行以编程方式进行.
Currently (1.1.0-beta02
and 1.2.0-alpha02
) you can't do it programmatically.
不过,您可以覆盖项目中的现有字符串,但是此解决方法可能会在以后的版本中停止运行.
However you can override the existing strings in your project, but this workaround can stop to run in the next releases.
对于确认和取消按钮,将以下字符串放入您的项目中:
For the confirm and the cancel buttons put in your projects these strings:
<string name="mtrl_picker_confirm" 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>
这篇关于在新的MaterialDatePicker中更改按钮文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!