Search in sources :

Example 56 with DrawerLayout

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();
    }
}
Also used : NavigationDrawer(ingage.ingage20.util.NavigationDrawer) ListView(android.widget.ListView) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 57 with DrawerLayout

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);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 58 with DrawerLayout

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);
        }
    });
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) MenuItem(android.view.MenuItem) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TabLayout(android.support.design.widget.TabLayout) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 59 with DrawerLayout

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);
        }
    }
}
Also used : DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 60 with DrawerLayout

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);
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) DrawerLayout(android.support.v4.widget.DrawerLayout) View(android.view.View)

Aggregations

DrawerLayout (android.support.v4.widget.DrawerLayout)63 View (android.view.View)59 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)33 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 AdapterView (android.widget.AdapterView)22 NavigationView (android.support.design.widget.NavigationView)21 ListView (android.widget.ListView)21 Intent (android.content.Intent)19 Toolbar (android.support.v7.widget.Toolbar)19 TextView (android.widget.TextView)15 ImageView (android.widget.ImageView)12 ActionBar (android.support.v7.app.ActionBar)9 SharedPreferences (android.content.SharedPreferences)8 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 ViewPager (android.support.v4.view.ViewPager)6 SuppressLint (android.annotation.SuppressLint)5 TabLayout (android.support.design.widget.TabLayout)5 ArrayList (java.util.ArrayList)5 ActionBar (android.app.ActionBar)4 TypedArray (android.content.res.TypedArray)4