的newInstance失败:无< INIT>

编程入门 行业动态 更新时间:2024-10-11 11:17:46
本文介绍了的newInstance失败:无< INIT>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不能实例化一个子活动。在logcat的我看到这行:

I cannot instantiate a sub activity. In the logcat I see this line:

01-22 15:14:38.906: DEBUG/dalvikvm(411): newInstance failed: no <init>()

这是该行的Dalvik的,其产生的logcat。

This is the line in dalvik that generates that logcat.

/* * public T newInstance() throws InstantiationException, IllegalAccessException * * Create a new instance of this class. */ static void Dalvik_java_lang_Class_newInstance(const u4* args, JValue* pResult) ... /* find the "nullary" constructor */ init = dvmFindDirectMethodByDescriptor(clazz, "<init>", "()V"); if (init == NULL) { /* common cause: secret "this" arg on non-static inner class ctor */ LOGD("newInstance failed: no <init>()\n"); dvmThrowExceptionWithClassMessage("Ljava/lang/InstantiationException;", clazz->descriptor); RETURN_VOID(); }

下面是我的行动采取激活一个计时器处理程序中的活动。

Here is the action I take to activate the activity in a timer handler.

// move on to Activation // ePNSplash is this activity a splash screen Intent i = new Intent (ePNSplash.this, Activation.class); startActivity (i);

这是我尝试启动活动是2扩展上述活动

The activity that I am trying to start is 2 extensions above Activity

这是第一个扩展

public abstract class AndroidScreen extends Activity { .... public AndroidScreen (String title, AndroidScreen parent, AndroidScreen main) { super (); myGlobals = Globals.getGlobals (); myGlobals.myLogger.logString("AndroidScreen: 001"); myParent = parent; myMainScreen = main; myTitle = title; }

这是唯一的构造,这似乎是有问题的部分。这里是第二个扩展和类我试图实例。

This is only the constructor, which seems to be the part that has the problem. Here is the 2nd extension and the class i am trying to instantiate.

public class Activation extends AndroidScreen { public Activation (String title, AndroidScreen parent, AndroidScreen main) { super (title, parent, main); }

我绝对困惑,我有一个构造函数,我要确保我打电话给我的超级构造函数,什么可能是错误的?

I am absolutely confused, I have a constructor, I make sure I call my super constructors, what could possibly be wrong?

感谢您

朱利安

推荐答案

dalvikvm的寻找一个零参数的构造函数(这就是他们所说的无元,如二进制的2个参数,一元1说法,它是无元0参数)。

dalvikvm's looking for a zero-argument constructor (that's what they mean by "nullary", as in "binary" for 2 arguments, "unary" for 1 argument, it's "nullary" for 0 arguments).

中的代码片段,你已经证明,你只有三个参数的构造函数。这是没有好。你不带参数进行实例化,所以你需要一个零参数的构造函数

in the snippet you've shown, you only have a three-argument constructor. that's no good: you'll be instantiated with no arguments, so you need a zero-argument constructor.

更多推荐

的newInstance失败:无&LT; INIT&GT;

本文发布于:2023-11-25 06:38:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628699.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:LT   newInstance   GT   INIT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!