title: super.onCreateView in Fragments
body: <p>I finished the Coursera course on Programming Mobile Applications for Android Handheld Systems. 
  One of the example code from the course teaches us how to us fragments. Basically what it does is it splits the screen into two fragments, one for book titles and one for quotes from the book. If a user clicks on a title in a fragment on the left, the quote associated from the book is displayed in fragment on the right.</p>
  
  <p><strong>This is the code for the mainActivity:</strong></p>
  
  <pre><code>package course.examples.Fragments.StaticLayout;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.util.Log;
  import course.examples.Fragments.StaticLayout.TitlesFragment.ListSelectionListener;
  
  public class QuoteViewerActivity extends Activity implements
          ListSelectionListener {
  
      public static String[] mTitleArray;
      public static String[] mQuoteArray;
      private QuotesFragment mDetailsFragment;
  
      private static final String TAG = "QuoteViewerActivity";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          mTitleArray = getResources().getStringArray(R.array.Titles);    
          mQuoteArray = getResources().getStringArray(R.array.Quotes);
  
          setContentView(R.layout.main);
  
          mDetailsFragment = (QuotesFragment) getFragmentManager()
                  .findFragmentById(R.id.details);        
      }
  
      @Override
      public void onListSelection(int index) {
          if (mDetailsFragment.getShownIndex() != index) {        
              mDetailsFragment.showQuoteAtIndex(index);
          }
      }
  </code></pre>
  
  <p><strong>This is the code for the Quote fragment:</strong></p>
  
  <pre><code>package course.examples.Fragments.StaticLayout;
  
  import android.app.Activity;
  import android.app.Fragment;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.TextView;
  
  public class QuotesFragment extends Fragment {
  
      private TextView mQuoteView = null;
      private int mCurrIdx = -1;
      private int mQuoteArrayLen;
  
      private static final String TAG = "QuotesFragment";
  
      public int getShownIndex() {
          return mCurrIdx;
      }
  
      public void showQuoteAtIndex(int newIndex) {
          if (newIndex &lt; 0 || newIndex &gt;= mQuoteArrayLen)
              return;
          mCurrIdx = newIndex;
          mQuoteView.setText(QuoteViewerActivity.mQuoteArray[mCurrIdx]);
      }
  @Override
  public void onAttach(Activity activity) {
      Log.i(TAG, getClass().getSimpleName() + ":entered onAttach()");
      super.onAttach(activity);
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      Log.i(TAG, getClass().getSimpleName() + ":entered onCreate()");
      super.onCreate(savedInstanceState);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      **return inflater.inflate(R.layout.quote_fragment, container, false);**
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {      
      super.onActivityCreated(savedInstanceState);
      mQuoteView = (TextView) getActivity().findViewById(R.id.quoteView);
      mQuoteArrayLen = QuoteViewerActivity.mQuoteArray.length;
  }
  </code></pre>
  
  <p><strong>This is the code for the title fragment:</strong></p>
  
  <pre><code>package course.examples.Fragments.StaticLayout;
  
  import android.app.Activity;
  import android.app.ListFragment;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  
  public class TitlesFragment extends ListFragment {
      private ListSelectionListener mListener = null;
      private static final String TAG = "TitlesFragment";
  
      public interface ListSelectionListener {
          public void onListSelection(int index);     
      }
  
      @Override
      public void onListItemClick(ListView l, View v, int pos, long id) {
          getListView().setItemChecked(pos, true);
          mListener.onListSelection(pos);
      }
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
          try {
              mListener = (ListSelectionListener) activity;
          } catch (ClassCastException e) {
              throw new ClassCastException(activity.toString()
                      + " must implement OnArticleSelectedListener");
          }
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          Log.i(TAG, getClass().getSimpleName() + ":entered onCreate()");
          super.onCreate(savedInstanceState);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          Log.i(TAG, getClass().getSimpleName() + ":entered onCreate()");
  
          **return super.onCreateView(inflater, container, savedInstanceState);**
  
      }
  
      @Override
      public void onActivityCreated(Bundle savedState) {
          super.onActivityCreated(savedState);
  
          getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
          setListAdapter(new ArrayAdapter&lt;String&gt;(getActivity(),
                  R.layout.title_item, QuoteViewerActivity.mTitleArray));
      }
  </code></pre>
  
  <p><strong>MainActivity xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:baselineAligned="false"
      android:orientation="horizontal" &gt;
  
      &lt;fragment
          android:id="@+id/titles"
          android:layout_width="0px"
          android:layout_height="match_parent"
          android:layout_weight="1"
          class="course.examples.Fragments.StaticLayout.TitlesFragment" /&gt;
  
      &lt;fragment
          android:id="@+id/details"
          android:layout_width="0px"
          android:layout_height="match_parent"
          android:layout_weight="2"
          class="course.examples.Fragments.StaticLayout.QuotesFragment" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Quote Fragments xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:id="@+id/quoteView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:padding="5dip"
          android:textSize="32sp" &gt;
      &lt;/TextView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Title fragment xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="?android:attr/activatedBackgroundIndicator"
      android:orientation="vertical"
      android:padding="5dip"
      android:textSize="32sp" &gt;
  
  &lt;/TextView&gt;
  </code></pre>
  
  <p>My question is why does the method under onCreateView differ under Quote fragment and Title fragment?
  QuoteFragment is <strong>return inflater.inflate(R.layout.quote_fragment, container, false);</strong>
  TitleFragment is <strong>return super.onCreateView(inflater, container, savedInstanceState);</strong></p>