Android Open Source - simple-matrix Settings Activity






From Project

Back to project page simple-matrix.

License

The source code is released under:

MIT License

If you think the Android project simple-matrix 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.alexkang.x3matrixcalculator;
/*from  w w w .jav  a  2s .  c om*/
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;

/**
 * A {@link PreferenceActivity} that presents a set of application settings. On
 * handset devices, settings are presented as a single list. On tablets,
 * settings are split by category, with category headers shown to the left of
 * the list of settings.
 * <p>
 * See <a href="http://developer.android.com/design/patterns/settings.html">
 * Android Design: Settings</a> for design guidelines and the <a
 * href="http://developer.android.com/guide/topics/ui/settings.html">Settings
 * API Guide</a> for more information on developing a Settings UI.
 */
public class SettingsActivity extends PreferenceActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setupActionBar();
    
    /* 
     * From API 11, addPreferencesFromResourcce() is deprecated.
     * Therefore, PreferenceFragment is now being used because of
     * support for headers.
     */
    getFragmentManager().
    beginTransaction().
    replace(android.R.id.content, new Preferences()).
    commit();
  }

  public static class Preferences extends PreferenceFragment {
    
    @Override
    public void onCreate(final Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.pref_general);
    }
  }
  
  /**
   * Set up the {@link android.app.ActionBar}, if the API is available.
   */
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void setupActionBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      // Show the Up button in the action bar.
      getActionBar().setDisplayHomeAsUpEnabled(true);
    }
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
      // This ID represents the Home or Up button. In the case of this
      // activity, the Up button is shown. Use NavUtils to allow users
      // to navigate up one level in the application structure. For
      // more details, see the Navigation pattern on Android Design:
      //
      // http://developer.android.com/design/patterns/navigation.html#up-vs-back
      //
      // that hierarchy.
      NavUtils.navigateUpFromSameTask(this);
      return true;
    }
    return super.onOptionsItemSelected(item);
  }
}




Java Source Code List

com.alexkang.x3matrixcalculator.DisplayResultActivity.java
com.alexkang.x3matrixcalculator.MainActivity.java
com.alexkang.x3matrixcalculator.MatrixRational.java
com.alexkang.x3matrixcalculator.Matrix.java
com.alexkang.x3matrixcalculator.SettingsActivity.java
com.alexkang.x3matrixcalculator.calculations.Advanced.java
com.alexkang.x3matrixcalculator.calculations.Basic.java
com.alexkang.x3matrixcalculator.calculations.RationalAdvanced.java
com.alexkang.x3matrixcalculator.calculations.RationalBasic.java
com.alexkang.x3matrixcalculator.calculations.RationalCalc.java
com.alexkang.x3matrixcalculator.calculations.Rational.java