title: Finding Fragment View on Activity. Android findFragmentByTag(String tag) returns null
body: <p>I'm trying to get a Spinner View from an added <code>Fragment</code> to my activity but it seems that I cannot get the fragment nor the view.</p>
  
  <p>I have an Activity which adds a <code>Fragment</code> to it's <code>LinearLayout</code>, the fragment's layout is based on the 'extra' that comes from the intent of the Activity. Everything is displayed correctly and I can see all the views of the fragment but for some reason when I call <code>findFragmentByTag(String tag)</code> it returns null and thus I cannot call getView().</p>
  
  <p>Here is how I am adding the fragment code to my activity:</p>
  
  <pre><code>...onCreate(){
      ...
      FragmentManager fm = getFragmentManager();
      FragmentTransaction ft = fm.beginTransaction();
  
      Fragment fr = new Fragment(){
          @Override
          public View onCreateView(LayoutInflater inflater,
                  ViewGroup container, Bundle savedInstanceState) {
              return inflater.inflate(layoutID, container, false);
          }
      };
      ft.add(R.id.formsListActivity_Container, fr, "form_fragment_tag");
  
      ft.commit();
      ...
  </code></pre>
  
  <p>}</p>
  
  <p>Then I try to get such fragment and get a the spinner view to add the string array:</p>
  
  <pre><code>Fragment f = fm.findFragmentByTag("form_fragment_tag");
  Spinner spinner = (Spinner) f.getView().findViewById(R.id.city_spinner);
  ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this, 
          R.array.city_list, android.R.layout.simple_spinner_item);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
  </code></pre>
  
  <p>But I get a null exception because findFragmentByTag() returns null</p>
  
  <p>What am I doing wrong? I've verified the code a few times and the tags are the same.
  I've also make sure the spinner's id is in the XML layout file correctly, and the fragment is loading the correct XML layout because I can see it (If a comment the get view from fragment part).</p>