title: Inflate a layout inside other layout's LinearLayout
body: <p>I've got this Layout:</p>
  
  <p><a href="http://img845.imageshack.us/img845/2121/d6zp.png" rel="nofollow noreferrer">ComposeView http://img845.imageshack.us/img845/2121/d6zp.png</a></p>
  
  <p>The 2 borders (left,right )are filled by icons. When I touch one of these icons I access to other activity. The top black bar is a custom title bar. </p>
  
  <p>The clear grey inside space is where I need to fit all activities that I've got on my app. So this layout would be something like a menu layout that would be static in all the activities.</p>
  
  <p>This is the Layout xml:</p>
  
  <p><strong>menu_view.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout     
  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" 
  tools:context="com.example.MenuView" &gt;
  
  
  &lt;!-- Show top black custom title bar--&gt;
  &lt;include 
      layout="@layout/custom_tittlebar" &gt;
  &lt;/include&gt;
  
  
  &lt;!-- Button columns --&gt;    
  &lt;LinearLayout 
      android:id="@+id/lefthandmenu"
      android:layout_width="85dip"
      android:layout_height="match_parent"
      android:layout_below="@id/title"
      android:layout_alignParentLeft="true"
      android:orientation="vertical"       
      android:background="@drawable/border_cut" &gt;
  
      &lt;ImageView
          ... /&gt;
          ...
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout 
      android:id="@+id/righthandmenu"
      android:layout_width="85dip"
      android:layout_height="match_parent"
      android:layout_below="@id/title"
      android:layout_alignParentRight="true"
      android:orientation="vertical"
      android:background="@drawable/border_cut" &gt;
  
      &lt;ImageView
          ... /&gt;
          ...
  &lt;/LinearLayout&gt;
  
  &lt;!-- Blank space which will contain other activities --&gt;
  &lt;LinearLayout
      android:id="@+id/activitycontent"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_toLeftOf="@id/righthandmenu"
      android:layout_toRightOf="@id/lefthandmenu"
      android:layout_below="@id/title"
      android:orientation="vertical" &gt;    
  &lt;/LinearLayout&gt;   
  </code></pre>
  
  <p></p>
  
  <p>And this is the class where are defined all the icon's onClickListeners.</p>
  
  <p><strong>MenuView.java</strong></p>
  
  <pre><code>public class MenuView extends RelativeLayout {
  
  private final LayoutInflater inflater;
  Context context;
  
  public MenuViewActivity(Context context, AttributeSet attrs) {
      super(context, attrs);
  
      this.context = context;
      inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      inflater.inflate(R.layout.menu_view, this, true);
  
  
      ((ImageView)this.findViewById(R.id.navButton)).setOnClickListener(launch_nav);
  }
  
  final OnClickListener launch_nav = new OnClickListener() {
      @Override
      public void onClick(View v) {
          getContext().startActivity(new Intent(getContext(), Navigation.class));
      }
  };
  </code></pre>
  
  <p>Well, having this (I'm not sure if its all ok, maybe I'm doing something wrong with the inflate method or something like this), now the thing would be to define the other activitie's layouts to be inside this view. To do this, I write:</p>
  
  <p><strong>ExampleActivity.java</strong></p>
  
  <pre><code>public class ExampleActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      LinearLayout inside_menu_view = (LinearLayout)findViewById(R.id.activitycontent);
  
      View this_layout = getLayoutInflater().inflate(R.layout.main, inside_menu_view, true);
      inside_menu_view.addView(this_layout);
  </code></pre>
  
  <p>But I'm getting a NullPointerException on this last line. So, something when inflating on this snippets must be wrong.</p>