title: How to render both an xml view and a java view in android
body: <p>In my app I have a very basic looking compass which is rendered within my activity through a class. I am trying to display the compass with a layout. So rather than having just a circle with a line pointing north, I can include text box and buttons. How do I render this within a layout? Currently my activity sets the content view like so:</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          compassView = new CompassView(this);
          setContentView(compassView);
  </code></pre>
  
  <p>I have tried <code>setContentView(R.layout.activity_display_compass)</code> which is my xml file however it only display <code>"hello world"</code> (the <code>TextView</code>), not the compass. See my xml file below.</p>
  
  <p>xml</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/hello_world"/&gt;
  
      &lt;View
          class = "com.example.gpsfinder.CompassView"
          android:id="@+id/compassView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Any guidance would be greatly appreciated.</p>