Android Open Source - ScienceQuiz New Game Activity






From Project

Back to project page ScienceQuiz.

License

The source code is released under:

GNU General Public License

If you think the Android project ScienceQuiz listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.finger.sciencequiz;
//  ww w.  j  a v  a2s .c  o m
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.ToggleButton;

public class NewGameActivity extends ActionBarActivity
{

    @Override
    protected void onCreate (Bundle savedInstanceState)
    {
  super.onCreate (savedInstanceState);
  setContentView (R.layout.activity_new_game);

  if (savedInstanceState == null)
  {
      getSupportFragmentManager ().beginTransaction ()
                            .add (
                                R.id.container,
                                new PlaceholderFragment ())
                            .commit ();
  }
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment
    {

  public PlaceholderFragment ()
  {
  }

  @Override
  public View onCreateView (LayoutInflater inflater, ViewGroup container,
                            Bundle savedInstanceState)
  {
      View rootView = inflater.inflate (
    R.layout.fragment_new_game,
    container,
    false);
      return rootView;
  }
    }

    public void toggleContactListState (View v)
    {
  boolean enabled = ((ToggleButton) v).isChecked ();
  v = findViewById (R.id.running_games_list_wrapper);
  ListView list = (ListView) findViewById (R.id.running_games_list);

  if (enabled)
  {
      setAlpha (v, 1f);
      list.setChoiceMode (AbsListView.CHOICE_MODE_SINGLE);
  }
  else
  {
      setAlpha (v, 0.5f);
      list.setChoiceMode (AbsListView.CHOICE_MODE_NONE);
  }
    }
    
    public void createNewGame (View v)
    {
  Intent intent = new Intent (this, GameTypeSelectActivity.class);
  startActivity (intent);
    }

    @SuppressLint ("NewApi")
    protected void setAlpha (View v, float a)
    {
  if (android.os.Build.VERSION.SDK_INT < 11)
  {
      android.view.animation.AlphaAnimation animation =
                new android.view.animation.AlphaAnimation (a, a);
      animation.setDuration (0);
      animation.setFillAfter (true);
      v.startAnimation (animation);
  }
  else
  {
      v.setAlpha (a);
  }
    }
}




Java Source Code List

com.finger.sciencequiz.AboutActivity.java
com.finger.sciencequiz.ConfigReader.java
com.finger.sciencequiz.FriendsHomeFragment.java
com.finger.sciencequiz.GalleryViewPager.java
com.finger.sciencequiz.GameActivity.java
com.finger.sciencequiz.GameTypeSelectActivity.java
com.finger.sciencequiz.HistoryActivity.java
com.finger.sciencequiz.HomePagerAdapter.java
com.finger.sciencequiz.ImageAdapter.java
com.finger.sciencequiz.LobbyActivity.java
com.finger.sciencequiz.MainActivity.java
com.finger.sciencequiz.NavigationDrawerFragment.java
com.finger.sciencequiz.NewGameActivity.java
com.finger.sciencequiz.ProfileHomeFragment.java
com.finger.sciencequiz.RotationTextView.java
com.finger.sciencequiz.RunningGamesHomeFragment.java
com.finger.sciencequiz.SettingsActivity.java
com.finger.sciencequiz.StartHomeFragment.java