Search in sources :

Example 6 with NavigationView

use of android.support.design.widget.NavigationView in project FlowingDrawer by mxn21.

the class MenuListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_menu, container, false);
    ivMenuUserProfilePhoto = (ImageView) view.findViewById(R.id.ivMenuUserProfilePhoto);
    NavigationView vNavigation = (NavigationView) view.findViewById(R.id.vNavigation);
    vNavigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            Toast.makeText(getActivity(), menuItem.getTitle(), Toast.LENGTH_SHORT).show();
            return false;
        }
    });
    setupHeader();
    return view;
}
Also used : NavigationView(android.support.design.widget.NavigationView) MenuItem(android.view.MenuItem) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View)

Example 7 with NavigationView

use of android.support.design.widget.NavigationView in project android by owncloud.

the class DrawerActivity method setupDrawer.

/**
     * Initializes the drawer and its content.
     * This method needs to be called after the content view has been set.
     */
protected void setupDrawer() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    if (mNavigationView != null) {
        mAccountChooserToggle = (ImageView) findNavigationViewChildById(R.id.drawer_account_chooser_toogle);
        mAccountChooserToggle.setImageResource(R.drawable.ic_down);
        mIsAccountChooserActive = false;
        mAccountMiddleAccountAvatar = (ImageView) findNavigationViewChildById(R.id.drawer_account_middle);
        mAccountEndAccountAvatar = (ImageView) findNavigationViewChildById(R.id.drawer_account_end);
        // ruining the generic avatars, so tinting for icons is deactivated pre lollipop
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            mNavigationView.setItemIconTintList(null);
        }
        setupDrawerContent(mNavigationView);
        findNavigationViewChildById(R.id.drawer_active_user).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                toggleAccountList();
            }
        });
    }
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            // standard behavior of drawer is to switch to the standard menu on closing
            if (mIsAccountChooserActive) {
                toggleAccountList();
            }
            invalidateOptionsMenu();
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mDrawerToggle.setDrawerIndicatorEnabled(true);
            invalidateOptionsMenu();
        }
    };
    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    mDrawerToggle.setDrawerIndicatorEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 8 with NavigationView

use of android.support.design.widget.NavigationView in project XposedInstaller by rovo89.

the class WelcomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ThemeUtil.setTheme(this);
    setContentView(R.layout.activity_welcome);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
    assert mNavigationView != null;
    mNavigationView.setNavigationItemSelectedListener(this);
    ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // this disables the arrow @ completed state
            super.onDrawerSlide(drawerView, 0);
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            // this disables the animation
            super.onDrawerSlide(drawerView, 0);
        }
    };
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    mSelectedId = mNavigationView.getMenu().getItem(prefs.getInt("default_view", 0)).getItemId();
    mSelectedId = savedInstanceState == null ? mSelectedId : savedInstanceState.getInt(SELECTED_ITEM_ID);
    mPrevSelectedId = mSelectedId;
    mNavigationView.getMenu().findItem(mSelectedId).setChecked(true);
    if (savedInstanceState == null) {
        mDrawerHandler.removeCallbacksAndMessages(null);
        mDrawerHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                navigate(mSelectedId);
            }
        }, 250);
        boolean openDrawer = prefs.getBoolean("open_drawer", false);
        if (openDrawer)
            mDrawerLayout.openDrawer(GravityCompat.START);
        else
            mDrawerLayout.closeDrawers();
    }
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        int value = extras.getInt("fragment", prefs.getInt("default_view", 0));
        switchFragment(value);
    }
    mRepoLoader = RepoLoader.getInstance();
    ModuleUtil.getInstance().addListener(this);
    mRepoLoader.addListener(this);
    notifyDataSetChanged();
}
Also used : SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 9 with NavigationView

use of android.support.design.widget.NavigationView in project AndResGuard by shwenzhang.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
Also used : NavigationView(android.support.design.widget.NavigationView) CrashlyticsNdk(com.crashlytics.android.ndk.CrashlyticsNdk) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) FloatingActionButton(android.support.design.widget.FloatingActionButton) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) Crashlytics(com.crashlytics.android.Crashlytics) Toolbar(android.support.v7.widget.Toolbar)

Example 10 with NavigationView

use of android.support.design.widget.NavigationView in project material-components-android by material-components.

the class TestUtilsActions method reinflateMenu.

/**
   * Clears and inflates the menu.
   *
   * @param menuResId The menu resource XML to be used.
   */
public static ViewAction reinflateMenu(@MenuRes final int menuResId) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(NavigationView.class);
        }

        @Override
        public String getDescription() {
            return "clear and inflate menu " + menuResId;
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            final NavigationView nv = (NavigationView) view;
            nv.getMenu().clear();
            nv.inflateMenu(menuResId);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : NavigationView(android.support.design.widget.NavigationView) ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) NavigationView(android.support.design.widget.NavigationView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

NavigationView (android.support.design.widget.NavigationView)59 View (android.view.View)36 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 Toolbar (android.support.v7.widget.Toolbar)21 TextView (android.widget.TextView)16 DrawerLayout (android.support.v4.widget.DrawerLayout)14 ImageView (android.widget.ImageView)14 UiController (android.support.test.espresso.UiController)12 ViewAction (android.support.test.espresso.ViewAction)12 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 Menu (android.view.Menu)7 Handler (android.os.Handler)6 ActionBar (android.support.v7.app.ActionBar)6 FlexboxLayout (com.google.android.flexbox.FlexboxLayout)6 Intent (android.content.Intent)5 FlakyTest (android.support.test.filters.FlakyTest)5 MediumTest (android.support.test.filters.MediumTest)5 SearchView (android.support.v7.widget.SearchView)5 MenuItem (android.view.MenuItem)5 AdapterView (android.widget.AdapterView)5