Back to project page ScienceQuiz.
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.
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); } } }