title: LayoutInflater in Activity
body: <p>I need help with LayoutInflater.
  In my project I'm getting "Avoid passing <code>null</code> as the view root (needed to resolve layout parameters..." lint warning.
  This warning is from Activity when in OnCreate method I have something like this:</p>
  
  <pre><code>LayoutInflater inflater =(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view = inflater.inflate(R.layout.my_view, null);
  </code></pre>
  
  <p>It's for inflate a header for example.</p>
  
  <p>I know that when I use LayoutInflater in Fragment or Adapter I have ViewGroup Object and I can pass it instead null but what should I do in this situation when it is in Activity? Should I supress this warning and pass null or create somehow parent object?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>public void addTextField(String message, int textSize) {
      LinearLayout field = (LinearLayout) getLayoutInflater().inflate(R.layout.text_view_field, null);
      TextView textView = (TextView) field.findViewById(R.id.taroTextView);
      textView.setText(message);
      textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
      textView.setSingleLine(false);
      mFieldsLayout.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  }
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>public class MyActionBarActivity extends ActionBarActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      ActionBar actionBar = getSupportActionBar();
      if (actionBar != null) {
          actionBar.setDisplayShowHomeEnabled(false);
          actionBar.setDisplayShowTitleEnabled(false);
          LayoutInflater inflater = LayoutInflater.from(this);
  
          View customView = inflater.inflate(R.layout.action_bar_layout, null);
          actionBar.setCustomView(customView);
          actionBar.setDisplayShowCustomEnabled(true);
      }
  }
  </code></pre>
  
  <p>}</p>