title: Pass data to Fragment from Layout before it's rendered
body: <p>I need to pass data to a fragment, declared in activity layout before it is rendered:</p>
  
  <pre><code>&lt;fragment android:name="com.app.fragments.MyFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/myFragment" /&gt;
  </code></pre>
  
  <p>I tried to do it in Activity's <code>onCreate</code> but fragment is already rendered at that time.</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      // Here fragment is already rendered
      mPosts = (MyFragment)getSupportFragmentManager().findFragmentById(R.id.myFragment);
      mPosts.setData(someData);
  }
  </code></pre>
  
  <p>I've seen the way when fragment is created programmatically in activity <code>onCreate</code> and than added to a container. It's not a very bad solution. But... Is there anything simpler?</p>