findViewById() returns null in TabActivity class
<p>I have NewTransferActivity class, which extends TabActivity. The code: </p>

<pre><code>public class NewTransferActivity extends TabActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.account_transfer);

    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;

    spec = tabHost.newTabSpec("receiver").setIndicator("Rec").setContent(getReceiverTab());
    tabHost.addTab(spec);

    spec = tabHost.newTabSpec("transfer").setIndicator("Trans").setContent(getTransferTab());
    tabHost.addTab(spec);

}

private TabContentFactory getReceiverTab(){
    TabContentFactory factory = new TabContentFactory() {
        @Override
        public View createTabContent(String tag) {

            ...

            return layout;
        }
    };
    return factory;
}

private TabContentFactory getTransferTab(){
    TabContentFactory factory = new TabContentFactory() {

        @Override
        public View createTabContent(String tag) {
            LinearLayout layout = (LinearLayout) findViewById(R.id.mytrans);

            if (layout == null){
                //layout = new LinearLayout(NewTransferActivity.this);
                System.out.println("NULL&gt;&gt;&gt;&gt;&gt;&gt;");
                return new LinearLayout(NewTransferActivity.this);
            }
            return layout;
        }
    };
    return factory;
} ...
</code></pre>

<p>my xml file, which contains layout is:</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mytrans"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" &gt;


&lt;TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" /&gt;

&lt;EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" &gt;

    &lt;requestFocus /&gt;
&lt;/EditText&gt;


&lt;TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" /&gt;

&lt;EditText
    android:id="@+id/editText2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" /&gt;


&lt;TextView
    android:id="@+id/textView3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" /&gt;

&lt;EditText
    android:id="@+id/editText3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" /&gt;


&lt;TextView
    android:id="@+id/textView4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" /&gt;

&lt;EditText
    android:id="@+id/editText4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>I want to load layout for a single tab from xml file which I definded. Unfortunatelly I am getting NullPointerException because layout is null in method getTransferTab(). 'LinearLayout layout = (LinearLayout) findViewById(R.id.mytrans)' returns null. What I am doing wrong? Thanks in advance.</p>
