Java tutorial
/** * Copyright (c) 2016 Rice University * * This software is subject to the provisions of the GNU Lesser General * Public License Version 2.1 (LGPL). See LICENSE.txt for details. */ package org.cnx.openstaxcnxmusic.activity; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import org.cnx.openstaxcnxmusic.R; import org.cnx.openstaxcnxmusic.fragments.AboutFragment; /** * Activity for About Us * @author Ed Woodward */ public class AboutActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(getString(R.string.about)); if (savedInstanceState == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); AboutFragment fragment = new AboutFragment(); transaction.replace(R.id.sample_content_fragment, fragment); transaction.commit(); } } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { Intent mainIntent = new Intent(getApplicationContext(), LandingActivity.class); mainIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(mainIntent); } return true; } }