Back to project page RaceTimer.
The source code is released under:
GNU General Public License
If you think the Android project RaceTimer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.liamfruzyna.android.racetimer; //w ww .j a v a2s.c o m import android.app.Fragment; import android.app.FragmentManager; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import com.liamfruzyna.android.racetimer.fragments.AddMeetFragment; import com.liamfruzyna.android.racetimer.fragments.AddTeamFragment; import com.liamfruzyna.android.racetimer.fragments.HomeFragment; public class RTActivity extends ActionBarActivity { Toolbar toolbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_rt); AppData.load(this.getFilesDir()); if (savedInstanceState == null) { getFragmentManager().beginTransaction().add(R.id.container, new HomeFragment()).commit(); } setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); toolbar = (Toolbar)this.findViewById(R.id.toolbar); } public void addToToolbar(View v) { toolbar.addView(v); } @Override public void onBackPressed() { Fragment tf = new HomeFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.container, tf).commit(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.rt, 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(); if (id == R.id.back) { Fragment tf = new HomeFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.container, tf).commit(); return true; } else if (id == R.id.new_team) { Fragment tf = new AddTeamFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.container, tf).commit(); return true; } else if (id == R.id.new_meet) { Fragment tf = new AddMeetFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.container, tf).commit(); return true; } return super.onOptionsItemSelected(item); } }