use of com.amqtech.opensource.appintroexample.ui.fragment.MainTabsFragment in project AppIntro by apl-devs.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar tb = (Toolbar) findViewById(R.id.toolbar);
tb.setTitle(getResources().getString(R.string.app_name));
tb.setTitleTextColor(Color.parseColor("#FFFFFF"));
PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(1).withName("Home");
PrimaryDrawerItem item2 = new PrimaryDrawerItem().withIdentifier(2).withName("Permissions");
new DrawerBuilder().withActivity(this).withHeader(R.layout.util_drawer_hdr).withToolbar(tb).addDrawerItems(item1, item2).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem != null) {
Fragment fragment = null;
FragmentManager fragmentManager = getFragmentManager();
switch((int) drawerItem.getIdentifier()) {
case 1:
fragment = new MainTabsFragment();
break;
case 2:
fragment = new PermissionTabsFragment();
break;
}
if (fragment != null) {
fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
}
if (drawerItem instanceof Nameable) {
setTitle(((Nameable) drawerItem).getName().getText(getApplicationContext()));
}
}
return false;
}
}).withShowDrawerOnFirstLaunch(true).withFireOnInitialOnClick(true).withSavedInstance(savedInstanceState).build();
}
Aggregations