开发者

ActiveAndroid - ClassCastException, any advice?

开发者 https://www.devze.com 2023-03-30 20:39 出处:网络
I am progressing in ActiveAndroid tutorial here: http://tracker.activeandroid.com/projects/activeandroid/wiki/Creating_your_database_model

I am progressing in ActiveAndroid tutorial here: http://tracker.activeandroid.com/projects/activeandroid/wiki/Creating_your_database_model

(whole getting started is here - http://tracker.activeandroid.com/projects/activeandroid/wiki/Getting_started)

Up to this point, I am encountering error - java.lang.ClassCastException I have implemented the same as it is written in the tutorial above. Problem is in class Category in method:

public Category(Context context) {
        super(context);
    }

LogCat output:

08-25 07:21:17.535: ERROR/AndroidRuntime(3788): Caused by: java.lang.ClassCastException: android.app.Application
08-25 07:21:17.535: ERROR/AndroidRuntime(3788): at com.activeandroid.ActiveRecordBase.<init>(ActiveRecordBase.java:33)
08-25 07:21:17.535: ERROR/AndroidRuntime(3788): at cz.kvados.test.ActiveAndroidTest.Category.<init>(Category.java:23)
08-25 07:21:17.535: ERROR/AndroidRuntime(3788): at cz.kvados.test.ActiveAndroidTest.ActiveAndroidTestActivity.onCreate(ActiveAnd开发者_如何学编程roidTestActivity.java:13)
08-25 07:21:17.535: ERROR/AndroidRuntime(3788): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-25 07:21:17.535: ERROR/AndroidRuntime(3788): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)

Anyone experienced with ActiveAndroid - Do you know what is the problem?

Thanks

Hmyzak


You likely are not extending Category from Activity. You need to make sure that you are passing this context into a valid constructor.

You need to make sure you are doing Category extends Activity in your class declaration.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号