私は以下のような1つのアクティビティクラスを書いています
public class HeaderFooter extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.headerfooter);
}
}
そして私はHeaderFooterクラスからもう1つのクラスを拡張しています
public class Home extends HeaderFooter
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
ViewGroup vg = (ViewGroup) findViewById(R.id.lldata);
ViewGroup.inflate(Home.this, R.layout.home, vg);
}
}
listitemclickイベントで基本クラスから拡張クラスを呼び出す方法
次のコードで試してみると
Intent i=new Intent(HeaderFooter .this, Home .class);
startActivity(i);
メインクラスから拡張クラスを呼び出す方法を教えてください。
例外の詳細:
03-21 07:17:44.173: E/AndroidRuntime(1522): FATAL EXCEPTION: main
03-21 07:17:44.173: E/AndroidRuntime(1522): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pcmac.parentconnect/com.pcmac.parentconnect.Grades}: java.lang.NullPointerException
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.os.Handler.dispatchMessage(Handler.java:99)
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.os.Looper.loop(Looper.java:137)
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-21 07:17:44.173: E/AndroidRuntime(1522): at java.lang.reflect.Method.invokeNative(Native Method)
03-21 07:17:44.173: E/AndroidRuntime(1522): at java.lang.reflect.Method.invoke(Method.java:511)
03-21 07:17:44.173: E/AndroidRuntime(1522): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-21 07:17:44.173: E/AndroidRuntime(1522): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-21 07:17:44.173: E/AndroidRuntime(1522): at dalvik.system.NativeStart.main(Native Method)
03-21 07:17:44.173: E/AndroidRuntime(1522): Caused by: java.lang.NullPointerException
03-21 07:17:44.173: E/AndroidRuntime(1522): at com.pcmac.parentconnect.LayerStack.onCreate(LayerStack.java:174)
03-21 07:17:44.173: E/AndroidRuntime(1522): at com.pcmac.parentconnect.Grades.onCreate(Grades.java:15)
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.app.Activity.performCreate(Activity.java:5104)
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-21 07:17:44.173: E/AndroidRuntime(1522): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-21 07:17:44.173: E/AndroidRuntime(1522): ... 11 more