title: LinearLayout inside another linearlayout always returning null
body: <p>this is the fragment where I am stuck. I want the layout_root to be recognized</p>
  
  <p>A Snippet of fragment_new_weather.xml</p>
  
  <pre><code>&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
      &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="wrap_content"
          android:paddingBottom="@dimen/activity_vertical_margin"
          android:paddingStart="@dimen/activity_horizontal_margin"
          android:paddingEnd="@dimen/activity_horizontal_margin"
          android:paddingTop="@dimen/activity_vertical_margin"
          tools:context="com.a5corp.weather.WeatherActivity$PlaceholderFragment"&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textAppearance="?android:attr/textAppearanceLarge"
              android:id="@+id/city_field"
              android:layout_alignParentTop="true"
              android:layout_centerHorizontal="true"
              android:textColor="#FFFFFF"
              android:ellipsize="end"
              android:maxLines="1"
              android:textSize="48sp" /&gt;
  
          &lt;LinearLayout
              android:orientation="horizontal"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:weightSum="1"
              android:id="@+id/linearLayout2"
              android:layout_below="@+id/daily_view"
              android:layout_alignParentStart="true"
              android:layout_alignParentLeft="true"&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:id="@+id/temp_text_view"
                      android:layout_height="wrap_content" /&gt;
  
                  &lt;LinearLayout
                      android:orientation="horizontal"
                      android:id="@+id/layout_root"
                      android:layout_width="wrap_content"
                      android:layout_height="match_parent" &gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:id="@+id/temp_text_view1"
                          android:layout_height="wrap_content" /&gt;
  
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_width="wrap_content"
                          android:layout_height="match_parent"
                          android:paddingStart="5dp"
                          android:minWidth="85sp"
                          android:paddingEnd="2dp"
                          android:layout_marginEnd="8dp"
                          android:paddingLeft="5dp"
                          android:paddingRight="2dp"
                          android:layout_marginRight="8dp"&gt;
  
                          &lt;TextView
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:textAppearance="?android:attr/textAppearanceLarge"
                              android:id="@+id/weather_icon1"
                              android:textSize="70sp"
                              android:textColor="#FFFFFF"
                              android:layout_gravity="center" /&gt;
  
                          &lt;TextView
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:textAppearance="?android:attr/textAppearanceMedium"
                              android:id="@+id/details_view1"
                              android:textColor="#FFFFFF" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
   &lt;!-- Code below this in the file works properly--&gt;
  </code></pre>
  
  <p>Here's the onCreateView of my fragment I'm stuck at :</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      //Working Code above
      layout = (LinearLayout) getActivity().findViewById(R.id.layout_root);
      if (layout == null)
          Log.e("NewFragment" , "Layout is null");
      if (rootView.findViewById(R.id.temp_text_view) == null)
          Log.e("NewFragment" , "Temp Text Is Null");
      if (rootView.findViewById(R.id.temp_text_view1) == null)
          Log.e("NewFragment" , "Temp Text 1 Is Null");
      //Working code below
  }
  </code></pre>
  
  <p>The problem is layout always returns null, whereas Neither temp_text_view (outside layout_root) and temp_text_view1 (inside layout_root) <strong>don't return</strong> null, whereas layout_root always returns null.</p>
  
  <p>Here's the code I'm trying to implement : </p>
  
  <pre><code>for (int i = 0; i &lt; 10; ++i) {
          LinearLayout child = new LinearLayout(getContext());
          child.setOrientation(LinearLayout.VERTICAL);
          child.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT , ViewGroup.LayoutParams.MATCH_PARENT));
          child.setPadding(5 , 0 , 2 , 0);
          child.setPaddingRelative(5 , 0 , 2 , 0);
  
          TextView wIcon = new TextView(getContext());
          TextView detField = new TextView(getContext());
  
          wIcon.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT , ViewGroup.LayoutParams.WRAP_CONTENT));
          wIcon.setTextSize(70);
          wIcon.setTextColor(Color.WHITE);
          wIcon.setTextAppearance(getContext() , android.R.style.TextAppearance_Large);
          wIcon.setGravity(Gravity.CENTER);
  
          detField.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT , ViewGroup.LayoutParams.WRAP_CONTENT));
          detField.setTextAppearance(getContext() , android.R.style.TextAppearance_Medium);
          detField.setTextColor(Color.WHITE);
  
          wIcon = weatherIcon[i];
          detField = detailsField[i];
          layout.addView(wIcon);
          layout.addView(detField);
      }
  </code></pre>