我将日历组件迁移到新的材料库df1 = (
df1[df1.Situation != x.Situation]
.append(x.drop(labels=['Outcome']), ignore_index=True)
.sort_values('Situation')
.reset_index(drop=True)
)
print(df1)
Situation Parameter 1 Parameter 2
0 0.0 0.000000 0.000000
1 1.0 0.000000 0.000000
2 2.0 0.000000 0.000000
3 3.0 0.000000 0.000000
4 4.0 0.000000 0.000000
5 5.0 0.000000 0.000000
6 6.0 0.000000 0.000000
7 7.0 0.000000 0.000000
8 8.0 2.301539 0.172428
9 9.0 0.000000 0.000000
10 10.0 0.000000 0.000000
中,但是在做一些简单的事情(如更改确认按钮文本的名称)时遇到了问题
以前足够
MaterialDatePicker
但是现在我找不到任何公共方法
datePickerDialog.setButton(DatePickerDialog.BUTTON_POSITIVE, getString(R.string.save), datePickerDialog)
答案 0 :(得分:1)
当前(1.1.0-beta02
和1.2.0-alpha02
)您无法以编程方式进行。
但是,您可以覆盖项目中的现有字符串,但是此解决方法可能会在以后的版本中停止运行。
对于在项目中放入以下字符串的确认和取消按钮:
<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>
答案 1 :(得分:0)
有一种解决方法,可以以编程方式设置按钮文本,最重要的是不要对整个项目进行设置。
创建日期选择器
val picker : MaterialDatePicker<*> = MaterialDatePicker.Builder.datePicker().build()
通过其ID查找肯定或否定按钮。
picker?.view?.findViewById<Button>(com.google.android.material.R.id.confirm_button)?.text =
"Your text here"
picker?.view?.findViewById<Button>(com.google.android.material.R.id.cancel_button)?.text =
"Your text here"
答案 2 :(得分:0)
更新自 1.4.0
我们仍然没有公共方法来为否定和肯定按钮提供自定义文本。出于某种原因,使用 findViewById<Button>(com.google.android.material.R.id.confirm_button).text = "some text"
对我不起作用。而是将以下行添加到您的字符串 xmls 以使用您的自定义文本。 (这将对应用程序产生广泛的影响!)这些与 @Gabriele Mariotti 提供的不同之处在于更新的字符串资源 ID。
<string description="Confirms the selection [CHAR_LIMIT=12]" name="mtrl_picker_save">Your positive button text</string>
<string name="cancel">Your negative button text</string>