Java tutorial
package be.ac.ucl.lfsab1509.bouboule; /* * This file is part of Bouboule. * * Copyright 2013 UCLouvain * * Authors: * * Group 7 - Course: http://www.uclouvain.be/en-cours-2013-lfsab1509.html * Matthieu Baerts <matthieu.baerts@student.uclouvain.be> * Baptiste Remy <baptiste.remy@student.uclouvain.be> * Nicolas Van Wallendael <nicolas.vanwallendael@student.uclouvain.be> * Helene Verhaeghe <helene.verhaeghe@student.uclouvain.be> * * Bouboule is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import be.ac.ucl.lfsab1509.bouboule.game.gameManager.GlobalSettings; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import android.view.Menu; import android.view.Window; import android.view.WindowManager; public class ChoosingActivity extends FragmentActivity { protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_main); /** Getting a reference to the ViewPager defined the layout file */ ViewPager pager = (ViewPager) findViewById(R.id.pager); /** Getting fragment manager */ FragmentManager fm = getSupportFragmentManager(); /** Instantiating FragmentPagerAdapter */ MyLevelPagerAdapter pagerAdapter = new MyLevelPagerAdapter(fm); /** Setting the pagerAdapter to the pager object */ pager.setAdapter(pagerAdapter); /** Select the current level */ int iWorld = (GlobalSettings.PROFILE.getBestLevel() - 1) / 4; // split in 4, we start with 0 pager.setCurrentItem(iWorld); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } public void onBackPressed() { setResult(be.ac.ucl.lfsab1509.bouboule.Menu.RETURN_MENU); finish(); } protected void onStop() { super.onStop(); MyAndroidMenus.onStopMusic(this); } @Override protected void onResume() { super.onResume(); MyAndroidMenus.onResumeMusic(this); } }