【发布时间】:2010-09-28 11:35:16
【问题描述】:
我的应用程序的结构...
Class A extends Activity {
Button cButton = (Button) findViewById(...);
Button dButton = (Button) findViewById(...);
//invoked when cButton is clicked
methodButtonC() {
//Here I want to go to the activity of class C and this is how I have tried to solve it...
Intent intent = new Intent(A.this, C.class);
startActivity(intent);
}
//invoked when dButton is clicked
methodButtonD() {
//Same problem as above but with Class D
}
}
// Base Class for C & D, No real purpose except sharing som methods to C & D (should probobly be abstract?)
Class B extends A {
// vairables and methods for inheritance
}
Class C extends B {
// uses derived methods and variables from Class B
}
Class D extends B {
// uses derived methods and variables from Class B
}
当我运行应用程序并单击按钮 C 或 D 时发生错误。我该怎么做?
【问题讨论】:
-
AndroidManifest.xml中提到你的所有活动吗? -
发生什么错误?至少给我们那么多。很有可能它说明了你做错了什么。
-
给你的按钮和你的类同名看起来让我有点困惑......
-
1.是的,每个活动都在 AndroidManifest.xml 2. 错误是 nullPointerException
标签: java android android-activity android-intent