title: How to inflate view inside fragment
body: <p>If I try to inflate a view within a fragment I am getting NULL.. For example:</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Here I will inflate my view using the layout ID &amp; return.
      return view;
  }
  </code></pre>
  
  <p>Whenever a button is clicked I need to create a dynamic view e.g.: button &amp; add to the LinearLayout. I would like to perform this operation inside my fragment class like this:</p>
  
  <pre><code>public void addPlaces() {    
      Button button = new Button(null);
      button.setText("button name");
      // e.g. like adding button to enter code here linear layout
      linearLayout.addView(button); 
  }
  </code></pre>
  
  <p>So, if I get inflate LinearLayout inside onCreateView and use it in add class, I'm getting NULL. How to achieve?</p>