From c5f7cee94356532e1f8c7cff6ec661e60295a7a1 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 4 Sep 2016 03:58:45 +0200 Subject: [PATCH] Using ToolBar in PreferencesActivity and SpecificActivity --- .../information/activity/PreferencesActivity.java | 12 ++++---- .../information/activity/SpecificActivity.java | 5 +++- app/src/main/res/layout/weather_preferences.xml | 35 ++++++++++++++++++++++ app/src/main/res/layout/weather_specific.xml | 1 + 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/layout/weather_preferences.xml diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/PreferencesActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/PreferencesActivity.java index e7a58c3..6754a68 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/PreferencesActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/PreferencesActivity.java @@ -18,26 +18,24 @@ package name.gumartinm.weather.information.activity; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import name.gumartinm.weather.information.R; -import name.gumartinm.weather.information.fragment.preferences.PreferencesFragment; public class PreferencesActivity extends AppCompatActivity { @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + this.setContentView(R.layout.weather_preferences); + + final Toolbar toolbar = (Toolbar) findViewById(R.id.weather_main_toolbar); + this.setSupportActionBar(toolbar); final ActionBar actionBar = this.getSupportActionBar(); - actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); actionBar.setIcon(R.drawable.ic_launcher); - - this.getFragmentManager() - .beginTransaction() - .replace(android.R.id.content, - new PreferencesFragment()).commit(); } @Override diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/SpecificActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/SpecificActivity.java index be25b0e..b6dc05d 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/SpecificActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/SpecificActivity.java @@ -18,6 +18,7 @@ package name.gumartinm.weather.information.activity; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import java.text.MessageFormat; import java.util.Locale; @@ -33,8 +34,10 @@ public class SpecificActivity extends AppCompatActivity { super.onCreate(savedInstanceState); this.setContentView(R.layout.weather_specific); + final Toolbar toolbar = (Toolbar) findViewById(R.id.weather_main_toolbar); + this.setSupportActionBar(toolbar); + final ActionBar actionBar = this.getSupportActionBar(); - actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); actionBar.setIcon(R.drawable.ic_launcher); diff --git a/app/src/main/res/layout/weather_preferences.xml b/app/src/main/res/layout/weather_preferences.xml new file mode 100644 index 0000000..c311702 --- /dev/null +++ b/app/src/main/res/layout/weather_preferences.xml @@ -0,0 +1,35 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/weather_specific.xml b/app/src/main/res/layout/weather_specific.xml index 7147a21..11c2d22 100644 --- a/app/src/main/res/layout/weather_specific.xml +++ b/app/src/main/res/layout/weather_specific.xml @@ -24,6 +24,7 @@ tools:context="name.gumartinm.weather.information.activity.SpecificActivity" tools:ignore="MergeRootFrame" > +