List of usage examples for android.support.v4.view GravityCompat START
int START
To view the source code for android.support.v4.view GravityCompat START.
Click Source Link
From source file:com.bluros.music.activities.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: { if (isNavigatingMain()) { mDrawerLayout.openDrawer(GravityCompat.START); } else//from w ww . j av a 2 s. com super.onBackPressed(); return true; } } return super.onOptionsItemSelected(item); }
From source file:com.github.rubensousa.navigationmanager.NavigationManager.java
public boolean openDrawer() { if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { return false; }//from ww w . j a va2s .c om mDrawerLayout.openDrawer(GravityCompat.START); return true; }
From source file:com.esri.arcgisruntime.sample.createsavemap.MainActivity.java
/*** * Called when invalidateOptionsMenu() is triggered *//* w w w . ja v a 2 s . co m*/ @Override public boolean onPrepareOptionsMenu(Menu menu) { // if nav drawer is opened, hide the action items if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { menu.findItem(R.id.action_save).setVisible(false); } else { menu.findItem(R.id.action_save).setVisible(true); } return super.onPrepareOptionsMenu(menu); }
From source file:com.example.meind.meinders_habittracker.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*from w ww. j ava2 s. c om*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_home) { // Handle the camera action } else if (id == R.id.nav_history) { Intent intent2 = new Intent(this, History_page.class); startActivity(intent2); } else if (id == R.id.nav_reset) { //got from //http://www.tutorialspoint.com/android/android_alert_dialoges.htm AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage("Are you sure you want to delete all data?"); alertDialogBuilder.setPositiveButton("yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { HabitListController.getHabitList().removeHabits(); HabitListController.getHabitList().notifyListener(); HabitListController.getHabitList().addListener(new Listener() { @Override public void update() { //updating the list once it gets deleted ListView listview = (ListView) findViewById(R.id.HabitList); final ArrayList<Habit> habitsArrayList = HabitListController.getHabitList() .getAllHabits(); final ArrayAdapter<Habit> HabitAdapter = new ArrayAdapter<Habit>(MainActivity.this, android.R.layout.simple_list_item_1, habitsArrayList); listview.setAdapter(HabitAdapter); HabitAdapter.notifyDataSetChanged(); } }); Toast.makeText(MainActivity.this, "All data has been deleted!", Toast.LENGTH_LONG).show(); } }); alertDialogBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //do nothing } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.he5ed.lib.cloudprovider.picker.CloudPickerActivity.java
/** * @hide/* w ww . ja v a2 s . co m*/ */ @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); // prepare cloud API setupApi(mAccounts[id]); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:co.dilaver.quoter.activities.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.qod: if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.str_QOD)); }// www.j a v a 2s . co m qodFavorite.setVisible(true); qodShare.setVisible(true); qodCopy.setVisible(true); wyoDone.setVisible(false); wyoShare.setVisible(false); pqInfo.setVisible(false); fragment = new QODFragment(); break; case R.id.qodPopular: if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.str_PopularQuotes)); } qodFavorite.setVisible(false); qodShare.setVisible(false); qodCopy.setVisible(false); wyoDone.setVisible(false); wyoShare.setVisible(false); pqInfo.setVisible(true); fragment = new PopularFragment(); break; case R.id.writeYourOwn: if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.str_WriteYourOwn)); } qodFavorite.setVisible(false); qodShare.setVisible(false); qodCopy.setVisible(false); wyoDone.setVisible(true); wyoShare.setVisible(true); pqInfo.setVisible(false); fragment = new WriteYourOwnFragment(); break; case R.id.aboutMe: if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.str_AboutMe)); } qodFavorite.setVisible(false); qodShare.setVisible(false); qodCopy.setVisible(false); wyoDone.setVisible(false); wyoShare.setVisible(false); pqInfo.setVisible(false); fragment = new AboutMeFragment(); break; case R.id.credits: if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.str_Credits)); } qodFavorite.setVisible(false); qodShare.setVisible(false); qodCopy.setVisible(false); wyoDone.setVisible(false); wyoShare.setVisible(false); pqInfo.setVisible(false); fragment = new CreditsFragment(); break; case R.id.favoriteQuotes: if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.str_FavoriteQuotes)); } qodFavorite.setVisible(false); qodShare.setVisible(false); qodCopy.setVisible(false); wyoDone.setVisible(false); wyoShare.setVisible(false); pqInfo.setVisible(false); fragment = new FavoriteQuotesFragment(); break; case R.id.settings: if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.str_Settings)); } qodFavorite.setVisible(false); qodShare.setVisible(false); qodCopy.setVisible(false); wyoDone.setVisible(false); wyoShare.setVisible(false); pqInfo.setVisible(false); fragment = new SettingsFragment(); break; } FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.mainFrame, fragment); ft.commit(); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerLayout.closeDrawer(GravityCompat.START); return true; }
From source file:com.actionbarsherlock.app.ActionBarSherlockDrawerToggle.java
/** * This method should be called by your <code>Activity</code>'s * {@link Activity#onOptionsItemSelected(android.view.MenuItem) * onOptionsItemSelected} method. If it returns true, your * <code>onOptionsItemSelected</code> method should return true and skip * further processing./*from w w w . ja va 2 s . c om*/ * * @param item * the MenuItem instance representing the selected menu item * @return true if the event was handled and further processing should not * occur */ public boolean onOptionsItemSelected(MenuItem item) { if (item != null && item.getItemId() == ID_HOME && mDrawerIndicatorEnabled) { if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) { mDrawerLayout.closeDrawer(GravityCompat.START); } else { mDrawerLayout.openDrawer(GravityCompat.START); } } return false; }
From source file:com.github.rubensousa.navigationmanager.NavigationManager.java
public boolean closeDrawer() { if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { mDrawerLayout.closeDrawer(GravityCompat.START); return true; }/*from ww w . j ava2s. c o m*/ return false; }
From source file:cn.zhangls.android.weibo.ui.home.HomeActivity.java
@Override public void onBackPressed() { if (mBinding.drawerLayout.isDrawerOpen(GravityCompat.START)) { mBinding.drawerLayout.closeDrawer(GravityCompat.START); } else {//from ww w . ja va 2 s .c o m moveTaskToBack(true);// ??Activity? super.onBackPressed(); } }
From source file:com.daiv.android.twitter.manipulations.widgets.ActionBarDrawerToggle.java
/** * Enable or disable the drawer indicator. The indicator defaults to enabled. * <p/>//from ww w.j ava 2s. com * <p>When the indicator is disabled, the <code>ActionBar</code> will revert to displaying * the home-as-up indicator provided by the <code>Activity</code>'s theme in the * <code>android.R.attr.homeAsUpIndicator</code> attribute instead of the animated * drawer glyph.</p> * * @param enable true to enable, false to disable */ public void setDrawerIndicatorEnabled(boolean enable) { if (enable != mDrawerIndicatorEnabled) { if (enable) { setActionBarUpIndicator(mSlider, mDrawerLayout.isDrawerOpen(GravityCompat.START) ? mOpenDrawerContentDescRes : mCloseDrawerContentDescRes); } else { setActionBarUpIndicator(mThemeImage, 0); } mDrawerIndicatorEnabled = enable; } }