Back to project page Navigation-drawer-a-la-Google.
The source code is released under:
Apache License
If you think the Android project Navigation-drawer-a-la-Google 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 info.korzeniowski.activitydrawersample; // w w w.ja v a 2s . c om import android.content.ComponentName; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceFragment; import android.support.v4.content.IntentCompat; import android.support.v7.widget.Toolbar; import android.view.View; import com.google.samples.apps.iosched.util.PrefUtils; public class SettingsActivity extends BaseDrawerActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar toolbar = getActionBarToolbar(); toolbar.setTitle("Settings"); toolbar.setNavigationIcon(R.drawable.ic_up); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { navigateUpToFromChild(SettingsActivity.this, IntentCompat.makeMainActivity( new ComponentName(SettingsActivity.this, FirstDrawerActivity.class))); } }); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new SettingsFragment()) .commit(); } } @Override protected int getSelfNavDrawerItem() { return NAVDRAWER_ITEM_SETTINGS; } @Override protected void onResume() { super.onResume(); invalidateOptionsMenu(); } public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public SettingsFragment() { } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupSimplePreferencesScreen(); PrefUtils.registerOnSharedPreferenceChangeListener(getActivity(), this); } @Override public void onDestroy() { super.onDestroy(); PrefUtils.unregisterOnSharedPreferenceChangeListener(getActivity(), this); } private void setupSimplePreferencesScreen() { addPreferencesFromResource(R.xml.preferences); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { } } }