Skip to content

Instantly share code, notes, and snippets.

@maydin
Created October 21, 2016 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maydin/d438c548b1b47e6c270b6b44ef4586ac to your computer and use it in GitHub Desktop.
Save maydin/d438c548b1b47e6c270b6b44ef4586ac to your computer and use it in GitHub Desktop.
Base Activity for pro flavor
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