Java tutorial
/* * Copyright (c) 2016 {UPRC}. * * OperandoApp 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. * * OperandoApp 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 OperandoApp. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Nikos Lykousas {UPRC}, Constantinos Patsakis {UPRC}, Periklis Maravelias * Initially developed in the context of OPERANDO EU project www.operando.eu */ package eu.operando.operandoapp.settings; import android.app.ActionBar; import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.support.v4.app.NavUtils; import android.view.MenuItem; import eu.operando.operandoapp.MainContext; import eu.operando.operandoapp.R; public class SettingActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { setTheme(MainContext.INSTANCE.getSettings().getThemeStyle().themeDeviceDefaultStyle()); super.onCreate(savedInstanceState); getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingPreferenceFragment()) .commit(); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); } public static class SettingPreferenceFragment extends PreferenceFragment { @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); } } }