Home > Blockchain >  Kotlin:How to make a popup date pick when click the EditText
Kotlin:How to make a popup date pick when click the EditText

Time:11-23

I would love to make a popup datepicker ,while click the EditText ,And the date can be set to different languages according to the device 's language .I will need it use Kotlin. More or less like as below : Could anyone show me an example please ? Thank you so much in advance !

enter image description here

I have tried this link ,but apppears two problems:

  1. The pop up dialog design is not what I expected . 2.The selected result can't fill into the EditText

enter image description here

CodePudding user response:

The default DatePicker looks like a calendar. You can change the behavior back to the old spinner style by adding this extra style in themes.xml.

<style name="MyDatePickerStyle" parent="android:Widget.Material.DatePicker">
    <item name="android:datePickerMode">spinner</item>
</style>

and then inside your style for the app's theme, add this line:

<item name="android:datePickerStyle">@style/MyDatePickerStyle</item>

Note that the calendar style is the default because it has been found to be preferred by most users.

  • Related