我正在尝试测试我创建的扩展 ImageView 的类。它在构造时崩溃了,显然是在运行任何代码之前(使用调试器单步执行并没有到达构造代码中的任何断点)。作为健全性检查,我创建了这个类:
package com.blah.thing;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
public class DoNothing extends ImageView {
public DoNothing(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public DoNothing(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public DoNothing(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
}
它仍然崩溃。我从一个基本上也什么都不做的活动中调用它(到目前为止):
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Context context = getApplicationContext();
DoNothing dn = new DoNothing(context);
setContentView(R.layout.main);
}
此活动位于主项目旁边的 Android 测试项目中......我需要做些什么来修复依赖关系或其他什么?顺便说一下,我正在导入我需要引用的所有包,如 DoNothing、Context 等。
谢谢!