title: Android Studio Coding
body: <p>My task is to convert an activity to a fragment.</p>
  
  <p>I did some changes but it still doesn't work. I am missing something, but I can't figure it out. One problem I do see is that the public class QuoteFragment extends SingleFregmentActivity is underline...not sure what I forget to do. Help please!</p>
  
  <p>When I wan converting the activity to a fragment what did I forget? </p>
  
  <p>Code for the activity...</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentActivity;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.content.Intent;
  
  /**
  * Main activity for the application.
   * Displays a series of quotes
   */
  public class QuoteFragment extends SingleFragmentActivity{
  /** Key for fact about author stored in Intent sent to AuthorFactActivity. */
  public static final String EXTRA_AUTHOR_FACT =
          "edu.andrews.cptr252.stephanien.quoteoftheday.author_fact";
  private static final String KEY_QUOTE_INDEX = "quoteIndex";
  /**ImageView used to display inspirational image*/
  private ImageView mImageView;
  
  private TextView mQuoteTextView;
  private TextView mAuthorTextView;
  private Button mNextButton;
  
  /**Quotes used in app */
  private Quote[] mQuoteList = new Quote[]{
          new Quote(R.string.quote_text_0, R.string.quote_author_0,
                  R.string.author_fact_0, R.drawable.mountain_pic),
          new Quote(R.string.quote_text_1, R.string.quote_author_1,
                  R.string.author_fact_1, R.drawable.lier),
          new Quote(R.string.quote_text_2, R.string.quote_author_2,
                  R.string.author_fact_2, R.drawable.math),
          new Quote(R.string.quote_text_3, R.string.quote_author_3,
                  R.string.author_fact_3, R.drawable.smiley),
          new Quote(R.string.quote_text_4, R.string.quote_author_4,
                  R.string.author_fact_4, R.drawable.th),
  };
  
  /** Index of current quote in list */
  private int mCurrentIndex = 0;
  
  /** Launch activity to display author fact */
  private void displayAuthorFact(){
      //Create intent with name of class for second activity.
      //This intent will be sent to the Activity Manager in the OS
      //Which will launch the activity.
      Intent i = new Intent(QuoteFragment.this, AuthorFactActivity.class);
      //Add extra containing resource id for fact
      i.putExtra(EXTRA_AUTHOR_FACT, mQuoteList[mCurrentIndex].getAuthorFact());
      //Send the intent to the activity manager.
      startActivity(i);
  }
  
  /**
   * Remember the current quote when the activity is destroyed
   * @param savedInstanceState Bundle used for saving identity of current quote
   */
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {
      super.onSaveInstanceState(savedInstanceState);
      //Stored the index of the current quote in the bundle.
      //Use our key to access the value later.
      savedInstanceState.putInt(KEY_QUOTE_INDEX, mCurrentIndex);
  }
  
  /**
   * Setup and inflate layout.
   * @param savedInstanceState Previously saved Bundle
   */
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      View v = inflater.inflate(R.layout.activity_fragment, container, false);
      //mQuoteTextView.setText("This should generate an error. Do you see why?");
  
      //Re-display the same quote we were on when activity destroyed
      if(savedInstanceState != null){
          mCurrentIndex = savedInstanceState.getInt(KEY_QUOTE_INDEX);
      }
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      //setSupportActionBar(toolbar);
  
      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View view) {
              Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                      .setAction("Action", null).show();
          }
      });
      //Display that text for the quote
      mQuoteTextView = (TextView) findViewById(R.id.quoteTextView);
      int quote = mQuoteList[mCurrentIndex].getQuote();
      mQuoteTextView.setText(quote);
      mQuoteTextView.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v) {
              displayAuthorFact();
          }
      });
  
      //Display the author of the quote
      mAuthorTextView = (TextView) findViewById(R.id.authorTextView);
      int author = mQuoteList[mCurrentIndex].getAuthor();
      mAuthorTextView.setText(author);
      mAuthorTextView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              displayAuthorFact();
          }
      });
  
      //Display image
      mImageView = (ImageView) findViewById(R.id.imageView);
      mImageView.setImageResource(R.drawable.mountain_pic);
  
      //set up listener to handle next button presses
      mNextButton = (Button) findViewById(R.id.nextButton);
      mNextButton.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v) {
              // move to the next quote in the list
              //if index reaches end array,
              //reset index to zero (first quote)
              mCurrentIndex++;
              if(mCurrentIndex == mQuoteList.length){
                  mCurrentIndex = 0;
              }
              updateQuote();
          }
      });
      return v;
  }
  /** Display the quote at the current index. */
  private void updateQuote(){
      int quote = mQuoteList[mCurrentIndex].getQuote();
      int author = mQuoteList[mCurrentIndex].getAuthor();
      int picture = mQuoteList[mCurrentIndex].getPicture();
      mQuoteTextView.setText(quote);
      mAuthorTextView.setText(author);
      mImageView.setImageResource(picture);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_quote, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  }
  </code></pre>