title: Access to view elements in fragments
body: <p>I have an activity which receive data from other activity. This data has to be showed in a TextView in a fragment inflated in the activity. So, the code is:</p>
  
  <pre><code>public class DetailActivity extends Activity {
  
  private int idEstablecimiento;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_detail);
  
      if (savedInstanceState == null) {
          getFragmentManager().beginTransaction()
                  .add(R.id.container, new PlaceholderFragment()).commit(); //Here the fragment is added to the activity
      }
  
      Bundle extras = getIntent().getExtras();
      if (extras != null) {
          idEstablecimiento = extras.getInt("idEstablecimiento");
      }
  
      TextView textView = (TextView) this.findViewById(R.id.nombreView); //Declared in fragmentDetail, which has been already inflated at this point, but still null
      textView.setText(this.idEstablecimiento);   
  }
  
  //...
  //Non related stuff...
  //...
  
      public static class PlaceholderFragment extends Fragment {
      private int idEstablecimiento;
      public PlaceholderFragment() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_detail,
                  container, false);
          return rootView;
      }
  }
  </code></pre>
  
  <p>The problem is that the textView in the onCreate() method is null, why is this happening if the fragment has been already inflated? Shouldn't I be able to access to the IU elements once the fragment has been inflated in the onCreate() method? Or if not, what is the rigth way to do access to it?</p>