【发布时间】:2014-07-15 07:43:03
【问题描述】:
这只是简单的 Android 代码
有一个文本视图和一个列表视图。
public class MaintActivity extends Activity {
private TextView text = (TextView)super.findViewById(R.id.text);
//cause android application crash
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
super.setContentView(R.layout.main);
//when I write this.text = (TextView) super.findViewById(R.id.text); here, I get rid of crashing
}
}
【问题讨论】:
-
错误是什么?顺便说一句,编译错误!= 运行时异常!= 崩溃。
-
这似乎是一个运行时异常,因为当我将其注释掉并在 OnCreat 成员方法中初始化 X 时,我摆脱了崩溃。
-
必须有一个堆栈跟踪,您可以为我们发布吗?没有它,我们将无法为您提供进一步的帮助。
-
对不起,我现在放上android代码,请帮帮我。