use of android.support.v4.widget.DrawerLayout in project iNGAGE by davis123123.
the class MainActivity method setupNavigationMenu.
/**
* Initializes the navigation drawer submit_post_toolbar to allow toggling via the toolbar or swipe from the
* side of the screen.
*/
private void setupNavigationMenu(final Bundle savedInstanceState) {
final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
final ListView drawerItems = (ListView) findViewById(R.id.nav_drawer_items);
// Create the navigation drawer.
navigationDrawer = new NavigationDrawer(this, toolbar, drawerLayout, drawerItems, R.id.main_fragment_container, mContext);
if (savedInstanceState == null) {
// Add the home fragment to be displayed initially.
navigationDrawer.showHome();
}
}
use of android.support.v4.widget.DrawerLayout in project NeuCardReader by liuyanyi.
the class MainActivity method viewInit.
private void viewInit() {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
use of android.support.v4.widget.DrawerLayout in project DevRing by LJYcoder.
the class MovieActivity method initEvent.
@Override
protected void initEvent() {
// 设置TabLayout选项卡的点击事件
mTlMovie.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
switch(tab.getPosition()) {
case 0:
clickPlaying();
break;
case 1:
clickComming();
break;
}
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
// 设置DrawerLayout滑动的相关监听
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close) {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
};
mDrawerToggle.syncState();
mDrawerLayout.addDrawerListener(mDrawerToggle);
mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
View mContent = mDrawerLayout.getChildAt(0);
mContent.setTranslationX(drawerView.getMeasuredWidth() * slideOffset);
}
@Override
public void onDrawerOpened(View drawerView) {
}
@Override
public void onDrawerClosed(View drawerView) {
}
@Override
public void onDrawerStateChanged(int newState) {
}
});
// 设置侧滑栏中的菜单项点击事件
mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch(item.getItemId()) {
case R.id.nav_item_collect:
startActivity(new Intent(MovieActivity.this, CollectActivity.class));
break;
case R.id.nav_item_upload:
startActivity(new Intent(MovieActivity.this, UploadActivity.class));
break;
case R.id.nav_item_download:
startActivity(new Intent(MovieActivity.this, DownloadActivity.class));
break;
}
// true则点击的菜单项会变成选中状态,,false则不会变成选中状态
return false;
}
});
mIvAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
RingToast.show(R.string.github_star);
}
});
}
use of android.support.v4.widget.DrawerLayout in project bugzy by cpunq.
the class HomeActivity method onBackPressed.
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
int count = getFragmentManager().getBackStackEntryCount();
if (count == 0) {
super.onBackPressed();
// additional code
} else {
getFragmentManager().popBackStack();
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
}
}
}
use of android.support.v4.widget.DrawerLayout in project DevRing by LJYcoder.
the class ColorBar method handleFitWindowForDrawer.
private void handleFitWindowForDrawer(Activity activity, boolean fit) {
ViewGroup parent = activity.findViewById(android.R.id.content);
for (int i = 0; i < parent.getChildCount(); i++) {
View childView = parent.getChildAt(i);
if (childView instanceof DrawerLayout) {
childView.setFitsSystemWindows(!fit);
((ViewGroup) childView).setClipToPadding(!fit);
View childViewOfDrawer = ((DrawerLayout) childView).getChildAt(0);
if (childViewOfDrawer instanceof ViewGroup) {
childViewOfDrawer.setFitsSystemWindows(fit);
((ViewGroup) childViewOfDrawer).setClipToPadding(fit);
}
}
}
}
Aggregations