如何使用nativescript javascript扩展?

How to use nativescript javascript extend?

我按照这个 guide 继承了一个 class,但是我崩溃了 dalvik.system.NativeStart.main(native method) 错误

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();

根据 Android 文档 (http://developer.android.com/reference/android/widget/DatePicker.html) DatePicker 构造函数至少采用一个参数(上下文)。尝试传递它,例如

var foo = new MyDatePicker(上下文);