FindViewByID on custom view returns null?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1691569/findviewbyid-returns-null-for-custom-component-in-layout-xml-not-for-other-com">findViewById() returns null for custom component in layout XML, not for other components</a>  </p>
</blockquote>



<p>Hi!
I cant reach my custom view with findViewById(). The reason I need to reach it, is because I want to make a menu from class A that interacts with class B. </p>

<p>The setup:
I got two classes A and B. A extends Activity and B extends View. 
I want to reach the B class from A, but when I use findViewById() on class B, it returns null. I have seen similar questions, but most of them just used the wrong .xml file. 
Here I am quite sure I use the right .xml file (R.layout.main) and in main.xml layes my 
viewTest. It runs smoothly and does what I want, unless I want to do something from class A to class B.. And, as far as I know, I need to use class A to create a menu I want.</p>

<p>Here is the piece from class A, in which I try to use findViewByID():</p>

<pre><code>viewTest viewTest;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    viewTest = (ViewTest) findViewById(R.id.snakes);

}
</code></pre>

<p>Here is the .xml file, from which I try to get the id snakes from:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;FrameLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"&gt;

&lt;com.Test.ViewTest 
    android:id="@+id/snakes"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /&gt;


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

<p>This has really been bugging me and I think the answer is right under my nose, I just can't see it >.&lt; Thanks in advance for any answer that can get me closer to solving this! :D</p>
