Creating a Drop Down list


#1

I am new to Native script mobile app development. I want to create a drop down list which shows some of the cities to select. Kindly help me regarding its code . I have searched almost all resources but could not implement it successfully . Kindly help me out

Regards
Nagendra Bhat


#2

Hey Nagendra Bhat

Unless you want to implement a dropdown view yourself, there are plugins that are readily available on npm.

The first result on Google:
https://www.npmjs.com/package/nativescript-drop-down

Available for both Android and iOS

Usage:

  • Include xmlns:dd="nativescript-drop-down" declaration in the Page tag where you’ll be using the dropdown.
  • <dd:DropDown items="{{ items }}" selectedIndex="{{ selectedIndex }}" opened="dropDownOpened" selectedIndexChanged="dropDownSelectedIndexChanged" />
    items is your array of values that will be selectable, in your case - cities.
    dropDownSelectedIndexChanged is the function callback that will be called when you select a value from the list.
    dropDownOpened is the callback that will fire when you initially open the dropdown.
    selectedIndex is a value bound to the view model that sets the current selection programatically.

#3

Thanks for the suggestion. My requirement is shifted from drop down to SearchBar now. I succeed with placing search bar in my activity I need a actual help now

I have a search bar in my home page when i click on it custom dialog should open to select the cities when i selects the city(Intent in android) Should pass to next page Right now when i click on the search bar. My keyboard …

Kindly Help me for this task. Your reply is more valueable

Regards
Nagendra Bhat