From 7c32f11a623fd2a8482808cb3e9df8d1121aa6a2 Mon Sep 17 00:00:00 2001 From: babaliaris Date: Tue, 10 Nov 2020 22:58:33 +0200 Subject: [PATCH] Added a button to open the drawer --- .../mthmmy/activities/main/MainActivity.java | 18 +++++++++++ app/src/main/res/layout/activity_main.xml | 32 ++++++++++++++----- app/src/main/res/values/strings.xml | 1 + 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index 5d8aa004..183211cc 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -5,6 +5,8 @@ import android.content.SharedPreferences; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; import android.widget.Toast; import androidx.appcompat.app.AppCompatDelegate; @@ -57,6 +59,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF private SectionsPagerAdapter sectionsPagerAdapter; private ViewPager viewPager; private TabLayout tabLayout; + private ImageView drawerButton; //Fix for vector drawables on android <21 static { @@ -89,6 +92,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF tabLayout = findViewById(R.id.tabs); viewPager = findViewById(R.id.container); + drawerButton = findViewById(R.id.main_activity_open_drawer_btn); //Create the adapter that will return a fragment for each section of the activity sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); @@ -110,6 +114,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF updateTabIcon(i); setMainActivity(this); + setDrawerButtonListener(); } @Override @@ -287,4 +292,17 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF } } } + + + private void setDrawerButtonListener() + { + this.drawerButton.setOnClickListener(new View.OnClickListener() + { + @Override + public void onClick(View v) + { + drawer.openDrawer(); + } + }); + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 053c2fb7..bc02d041 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -14,16 +14,32 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ToolbarTheme"> - + android:orientation="horizontal" + > + + + + + + SessionSharedPrefs + Button to open the drawer menu