Search in sources :

Example 81 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project FadingActionBar-Native by ManuelPeinado.

the class NavigationDrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_drawer);
    mTitle = mDrawerTitle = getTitle();
    mCityNames = getResources().getStringArray(R.array.drawer_items);
    TypedArray typedArray = getResources().obtainTypedArray(R.array.city_images);
    mCityImages = new int[typedArray.length()];
    for (int i = 0; i < typedArray.length(); ++i) {
        mCityImages[i] = typedArray.getResourceId(i, 0);
    }
    typedArray.recycle();
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mCityNames));
    mDrawerList.setOnItemClickListener(this);
    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
    R.string.drawer_open, /* "open drawer" description for accessibility */
    R.string.drawer_close) {

        /* "close drawer" description for accessibility */
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    if (savedInstanceState == null) {
        selectItem(0);
    }
}
Also used : TypedArray(android.content.res.TypedArray) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 82 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project Side-Menu.Android by Yalantis.

the class MainActivity method setActionBar.

private void setActionBar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    drawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    drawerLayout, /* DrawerLayout object */
    toolbar, /* nav drawer icon to replace 'Up' caret */
    R.string.drawer_open, /* "open drawer" description */
    R.string.drawer_close) {

        /* "close drawer" description */
        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            linearLayout.removeAllViews();
            linearLayout.invalidate();
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            if (slideOffset > 0.6 && linearLayout.getChildCount() == 0)
                viewAnimator.showMenuContent();
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 83 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project DraggablePanel by pedrovgs.

the class PlacesSampleActivity method configNavigationDrawer.

private void configNavigationDrawer() {
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    drawerlayoutLeft.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT);
    drawerToggle = new ActionBarDrawerToggle(this, drawerlayoutLeft, R.drawable.nav_drawer, R.string.app_name, R.string.app_name) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            draggablePanel.slideHorizontally(slideOffset, ViewHelper.getX(drawerView), drawerView.getWidth());
        }
    };
    drawerlayoutLeft.setDrawerListener(drawerToggle);
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 84 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project T-MVP by north2016.

the class HomeActivity method initView.

@Override
public void initView() {
    ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mViewBinding.dlMainDrawer, R.string.drawer_open, R.string.drawer_close);
    mDrawerToggle.syncState();
    mViewBinding.dlMainDrawer.addDrawerListener(mDrawerToggle);
    mViewBinding.nvMainNavigation.setNavigationItemSelectedListener(this);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle)

Example 85 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project AisenWeiBo by wangdan.

the class MainActivity method setupDrawer.

private void setupDrawer(Bundle savedInstanceState) {
    drawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, getToolbar(), R.string.draw_open, R.string.draw_close) {

        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };
    mDrawerLayout.setDrawerListener(drawerToggle);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) View(android.view.View)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)91 View (android.view.View)80 NavigationView (android.support.design.widget.NavigationView)34 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)34 TextView (android.widget.TextView)32 Toolbar (android.support.v7.widget.Toolbar)31 AdapterView (android.widget.AdapterView)30 DrawerLayout (android.support.v4.widget.DrawerLayout)29 ListView (android.widget.ListView)29 ActionBar (android.support.v7.app.ActionBar)20 ImageView (android.widget.ImageView)18 Intent (android.content.Intent)15 SharedPreferences (android.content.SharedPreferences)15 RecyclerView (android.support.v7.widget.RecyclerView)9 SearchView (android.support.v7.widget.SearchView)8 MenuItem (android.view.MenuItem)7 Handler (android.os.Handler)6 PackageManager (android.content.pm.PackageManager)5 InjectView (butterknife.InjectView)5 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)5