jasonmamy / cordova-wheel-selector-plugin

Wheel selector for Cordova (Android/iOS)
MIT License
65 stars 36 forks source link

default example from documentation does not work in Cordova 8.1.2 (cordova-lib@8.1.1), both android and iOS #48

Closed BorisKingma closed 5 years ago

BorisKingma commented 5 years ago

this code returns an empty selector on iOS (but title is set), and returns the following error on android java.lang.IllegalArgumentException: maxValue must be >= 0 at android.widget.NumberPicker.setMaxValue(NumberPicker.java:1464)

-- cordova version Cordova 8.1.2 (cordova-lib@8.1.1) ---code from documentation

  var data = {
                numbers: [
                    {description: "1"},
                    {description: "2"},
                    {description: "3"},
                    {description: "4"},
                    {description: "5"},
                    {description: "6"},
                    {description: "7"},
                    {description: "8"},
                    {description: "9"},
                    {description: "10"}
                ],
                fruits: [
                    {description: "Apple"},
                    {description: "Orange"},
                    {description: "Pear"},
                    {description: "Banana"},
                    {description: "Grapefruit"},
                    {description: "Tangerine"}
                ],
                measurements: [
                    {description: "Teaspoon"},
                    {description: "Tablespoon"},
                    {description: "Cup(s)"},
                    {description: "Quart(s)"},
                    {description: "Packages (7 oz)"},
                    {description: "Packages (12 oz)"}
                ],
                planets: [
                    {description: "Venus"},
                    {description: "Jupiter"},
                    {description: "Earth"},
                    {description: "Pluto"},
                    {description: "Neptune"}
                ]
            };

            var config = {
                title: "Select a quantity",
                items:[
                    data.numbers
                ],
                positiveButtonText: "Done",
                negativeButtonText: "Cancel"
            };
            window.SelectorCordovaPlugin.showSelector(config, function(result) {
                console.log("result: " + JSON.stringify(result) );
            }, function() {
                console.log('Canceled');
            });
jasonmamy commented 5 years ago

There's an error in the docs that was recently fixed, try: ... items: [ [data.numbers] ], ...

On Wed, Feb 13, 2019 at 8:04 AM Boris notifications@github.com wrote:

this code returns an empty selector on iOS (but title is set), and returns the following error on android java.lang.IllegalArgumentException: maxValue must be >= 0 at android.widget.NumberPicker.setMaxValue(NumberPicker.java:1464)

-- cordova version Cordova 8.1.2 (cordova-lib@8.1.1) ---code from documentation


var data = {
numbers: [
{description: "1"},
{description: "2"},
{description: "3"},
{description: "4"},
{description: "5"},
{description: "6"},
{description: "7"},
{description: "8"},
{description: "9"},
{description: "10"}
],
fruits: [
{description: "Apple"},
{description: "Orange"},
{description: "Pear"},
{description: "Banana"},
{description: "Grapefruit"},
{description: "Tangerine"}
],
measurements: [
{description: "Teaspoon"},
{description: "Tablespoon"},
{description: "Cup(s)"},
{description: "Quart(s)"},
{description: "Packages (7 oz)"},
{description: "Packages (12 oz)"}
],
planets: [
{description: "Venus"},
{description: "Jupiter"},
{description: "Earth"},
{description: "Pluto"},
{description: "Neptune"}
]
};

      var config = {
          title: "Select a quantity",
          items:[
              data.numbers
          ],
          positiveButtonText: "Done",
          negativeButtonText: "Cancel"
      };
      window.SelectorCordovaPlugin.showSelector(config, function(result) {
          console.log("result: " + JSON.stringify(result) );
      }, function() {
          console.log('Canceled');
      });

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/48>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ9UxjsC3XQkFQhW1pDgjqz1IJGFWONhks5vNDeBgaJpZM4a5up4>
.
BorisKingma commented 5 years ago

Works like a charm, thanks for responding so quickly!