TabHost.onTabChanged
<p>I've got a problem. I have three tabs (tid1, tid2, tid3). I'm properly returning <code>ProfileTab</code> ID (checked with Toast - tid2) and according to that fact I'm trying to <code>requestFocus()</code> on a <code>TextView</code> element from <code>ProfileTab</code>, so that when someone change tab to <code>ProfileTab</code> it should focus on that element.</p>

<p>File with Tabs: <code>Main.java</code>
File with ProfileTab: <code>Profile.java</code> (public)</p>

<p>I did something like this (Main.java):</p>

<pre><code>    tabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override
        public void onTabChanged(String tabId) {
            Defines.CURRENT_TAB = tabHost.getCurrentTabTag();
            if (Defines.CURRENT_TAB.equals(Defines.profileTab)) {
                Profile pTab = new Profile();
                pTab.tvGender.requestFocus();
            }

        }
    });
</code></pre>

<p>I get:</p>

<pre><code>E/AndroidRuntime(  542): FATAL EXCEPTION: main
E/AndroidRuntime(  542): java.lang.NullPointerException
E/AndroidRuntime(  542):    at com.application.core.Main$1.onTabChanged(Main.java:42)
E/AndroidRuntime(  542):    at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:356)
E/AndroidRuntime(  542):    at android.widget.TabHost.setCurrentTab(TabHost.java:341)
E/AndroidRuntime(  542):    at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:129)
E/AndroidRuntime(  542):    at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:453)
E/AndroidRuntime(  542):    at android.view.View.performClick(View.java:2408)
E/AndroidRuntime(  542):    at android.view.View$PerformClick.run(View.java:8816)
E/AndroidRuntime(  542):    at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(  542):    at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(  542):    at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  542):    at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(  542):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  542):    at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  542):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(  542):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(  542):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(   58):   Force finishing activity com.application.core/.Main
</code></pre>

<p>Anyone able to help?</p>
