Getting NullPointerException on the objects of class while splitting
<p>I have a class named as <code>TestApp</code> which extends <code>Activity</code> and another class named as <code>SecondClass</code> which extends <code>TestApp</code>.  In <code>TestApp</code> Activity I have a method which is setting text on button. When I am moving from <code>TestApp</code> to <code>SecondClass</code> and calling the method of <code>TestApp</code> from <code>SecondClass</code> getting <code>NullPointerException</code> on the button's object. Why is this happening ? Any suggestion would be appreciable.
here is my first Activity code.</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    ok = (Button) findViewById(R.id.button1);
    cancel = (Button) findViewById(R.id.button2);
    setTextAgain();
}

protected void setTextAgain() {
    ok.setText("hi");
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    menu.add(0, 0, 1, "1");
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case 0:
        SecondClass second = new SecondClass(this);
        second.initialize();
        break;
            }
    return super.onOptionsItemSelected(item);
}
</code></pre>

<p>here is my Second class code</p>

<pre><code>public class SecondClass extends TestAppActivity{

Context l_context;

public SecondClass(TestAppActivity p_testAppActivity) {

    l_context = p_testAppActivity;

}

public void initialize() {

    setTextAgain();

}
</code></pre>

<p>This is the logCat o/p</p>

<pre><code>02-17 22:43:54.159: E/AndroidRuntime(1246): java.lang.NullPointerException
02-17 22:43:54.159: E/AndroidRuntime(1246):     at       
android.app.Activity.setContentView(Activity.java:1657)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at    
com.sachit.testApp.TestAppActivity.setTextAgain(TestAppActivity.java:25)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at
com.sachit.testApp.SecondClass.initialize(SecondClass.java:17)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at    
com.sachit.testApp.TestAppActivity.onOptionsItemSelected(TestAppActivity.java:46)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at   
android.app.Activity.onMenuItemSelected(Activity.java:2205)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at   
com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:748)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at   
com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at 
com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at  
com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at   
com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at    
android.view.View$PerformClick.run(View.java:9080)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at   
android.os.Handler.handleCallback(Handler.java:587)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at   
android.os.Handler.dispatchMessage(Handler.java:92)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at   
android.os.Looper.loop(Looper.java:123)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at 
android.app.ActivityThread.main(ActivityThread.java:3683)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at 
java.lang.reflect.Method.invokeNative(Native Method)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at   
java.lang.reflect.Method.invoke(Method.java:507)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-17 22:43:54.159: E/AndroidRuntime(1246):     at     
dalvik.system.NativeStart.main(Native Method)
</code></pre>
