How to use nativescript javascript extend?

347 views Asked by At

I follow this guide to inherit a class, but i get crash with dalvik.system.NativeStart.main(native method) error

var MyDatePicker = android.widget.DatePicker.extend({
    init: function() {
        var isConstructor = arguments[arguments.length - 1];
        if (isConstructor) {
            // we are called from Java constructor
            console.log('con')
        } else  {
            // we are called from Java init method
            console.log('init');
        }
    }
});

var foo = new MyDatePicker();
1

There are 1 answers

0
Mihail Slavchev On BEST ANSWER

According Android documentation (http://developer.android.com/reference/android/widget/DatePicker.html) DatePicker constructor takes at least one parameter (context). Try passing it, for example

var foo = new MyDatePicker(context);