0

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

1 回答 1

1

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

var foo = new MyDatePicker(context);

于 2015-06-22T13:59:34.117 回答