Karteek
Karteek

Reputation: 138

Enabling date picker for a text field on click on it : nativescript

I'm developing a mobile app for android using "Native Script".

I want to enable a date picker to select date on clicking of a text field (I can't attach image here.The link for the date picker how i want is "https://i.sstatic.net/r7Rfj.png").

I tried DatePicker which is readily available in Native Script, It will display only Datepicker alone. But what I needed is Text field should be there, On click on text field need to prompt the date picker to pick the date( Using Native Script ).

Any help is very appreciative.Please excuse me if my English is poor. Thanks in advance.

Upvotes: 0

Views: 2259

Answers (2)

Abdullah
Abdullah

Reputation: 39

another way to do it is using NativeScript DateTimePicker plugin.

  • tns plugin add nativescript-datetimepicker
  • If you are developing a NativeScript Angular app, you need to import the plugin module in the module of your component.

<DatePickerField hint="select date"></DatePickerField>

https://github.com/NativeScript/nativescript-datetimepicker

Upvotes: 0

Guillaume
Guillaume

Reputation: 844

I think you have 2 ways to achieve that :

  • Add your DatePicker below your TextField in collapse mode. When the user taps on the TexField, show your DatePicker and hide it when a date is selected.

  • Create a modal view with your DatePicker inside. When the user taps on the TextField (on taps on a Button 'Select the date'), show your modal.

Upvotes: 3

Related Questions