Created
October 21, 2016 08:10
-
-
Save maydin/d438c548b1b47e6c270b6b44ef4586ac to your computer and use it in GitHub Desktop.
Base Activity for pro flavor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
} | |
@Override | |
public void setContentView(int layoutResID) { | |
final DrawerLayout fullView = (DrawerLayout) getLayoutInflater().inflate(R.layout.activity_base, null); | |
FrameLayout activityContainer = (FrameLayout) fullView.findViewById(R.id.activity_content); | |
getLayoutInflater().inflate(layoutResID, activityContainer, true); | |
super.setContentView(fullView); | |
final NavigationView navigationView = (NavigationView) fullView.findViewById(R.id.navigationView); | |
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { | |
@Override | |
public boolean onNavigationItemSelected(@NonNull MenuItem item) { | |
switch (item.getItemId()) { | |
case R.id.action_log: | |
fullView.closeDrawers(); | |
return true; | |
default: | |
return false; | |
} | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment