title: Inflate layout inside LinearLayout
body: <p>In the app that I'm developing, I have a Menu with icons that is on the right and left edges of the screen, and it mantains there in all the app's activities.</p>
  
  <p>What I've done is first create the "MenuView" class (wich may extend View, RelativeLayout, or something else)where are defined all the menu's icons and their onClickListeners. Then the layout for this class. In the layout I stablished 2 linearlayout's wich are each one on the border's of the screen (These refers to the menu) and a LinearLayout with the blank space inside the columns, where the other activities must go.</p>
  
  <p><strong>MenuViewActivity.java</strong></p>
  
  <pre><code>public class MenuViewActivity extends {
  
  public MenuViewActivity(Context context, AttributeSet attrs) {
      super(context, attrs);
      ...
  
      ((ImageView)this.findViewById(R.id.navButton)).setOnClickListener(launch_nav);
  
      final OnClickListener launch_nav = new OnClickListener() {
          @Override
          public void onClick(View v) {
              getBaseContext().startActivity(new Intent(getBaseContext(), Navigation.class));
          }
      };
      ...
  </code></pre>
  
  <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.MenuViewActivity" &gt;
  
  
  &lt;!-- Shows custom time titlebar --&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>So, what I must do now is to tell the program that other activities must go inside this last layout. For this, I do this in for example the Main class. <strong>I inflate the layout.</strong></p>
  
  <p><strong>MainClass.java</strong></p>
  
  <pre><code>public class MainClass extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
      super.onCreate(savedInstanceState);
  
  
      LinearLayout inside_menu_view = (LinearLayout)findViewById(R.id.activitycontent);
      View this_layout = getLayoutInflater().inflate(R.layout.main, inside_menu_view);
      inside_menu_view.addView(this_layout);
  </code></pre>
  
  <p>But I'm getting an error on the logcat:</p>
  
  <p><strong>UPDATE - After modifications still not working, this is the LogCat</strong></p>
  
  <pre><code>10-31 09:35:17.521: E/AndroidRuntime(1676): FATAL EXCEPTION: main
  10-31 09:35:17.521: E/AndroidRuntime(1676): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainClass}: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.MenuViewActivity
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.os.Handler.dispatchMessage(Handler.java:99)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.os.Looper.loop(Looper.java:130)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.app.ActivityThread.main(ActivityThread.java:3683)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at java.lang.reflect.Method.invoke(Method.java:507)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at dalvik.system.NativeStart.main(Native Method)
  10-31 09:35:17.521: E/AndroidRuntime(1676): Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.MenuViewActivity
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at com.masermic.medialauncher.LauncherActivity.onCreate(LauncherActivity.java:67)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     ... 11 more
  10-31 09:35:17.521: E/AndroidRuntime(1676): Caused by: java.lang.reflect.InvocationTargetException
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at java.lang.reflect.Constructor.constructNative(Native Method)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     ... 19 more
  10-31 09:35:17.521: E/AndroidRuntime(1676): Caused by: java.lang.NullPointerException
  10-31 09:35:17.521: E/AndroidRuntime(1676):     at com.mexample.MenuViewActivity.&lt;init&gt;(MenuViewActivity.java:55)
  10-31 09:35:17.521: E/AndroidRuntime(1676):     ... 22 more
  </code></pre>