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;
}
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);
}
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();
}
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);
}
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();
}
};
}
Aggregations