Skip to content

Commit

Permalink
Fix Navigation View issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ccjeng committed Feb 28, 2016
1 parent 6d23293 commit 740094f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.oddsoft.buddhavoice2"
minSdkVersion 16
targetSdkVersion 21
versionCode 25
versionName '2.3.3.022416BV'
versionCode 26
versionName '2.3.4.022816BV'
}
buildTypes {
release {
Expand Down
39 changes: 37 additions & 2 deletions app/src/main/java/com/oddsoft/buddhavoice2/view/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;

import com.google.android.gms.ads.AdRequest;
Expand Down Expand Up @@ -125,8 +127,17 @@ private void initDrawer() {
navigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
int id = menuItem.getItemId();
switch (id) {

//Checking if the item is in checked state or not, if not make it in checked state
if(menuItem.isChecked())
menuItem.setChecked(false);
else
menuItem.setChecked(true);

//Closing drawer on item click
drawerLayout.closeDrawers();

switch (menuItem.getItemId()) {
case R.id.navSetting:
startActivity(new Intent(MainActivity.this, Prefs.class));
break;
Expand Down Expand Up @@ -158,6 +169,30 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
.icon(GoogleMaterial.Icon.gmd_info)
.color(Color.GRAY)
.sizeDp(24));


ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerLayout,toolbar
,R.string.app_name, R.string.app_name){

@Override
public void onDrawerClosed(View drawerView) {
// Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank
super.onDrawerClosed(drawerView);
}

@Override
public void onDrawerOpened(View drawerView) {
// Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank

super.onDrawerOpened(drawerView);
}
};

//Setting the actionbarToggle to drawer layout
drawerLayout.setDrawerListener(actionBarDrawerToggle);

//calling sync state is necessay or else your hamburger icon wont show up
actionBarDrawerToggle.syncState();
}

@Override
Expand Down

0 comments on commit 740094f

Please sign in to comment.