Example #1
1
  /**
   * 为 DrawerLayout 布局设置状态栏透明
   *
   * @param activity 需要设置的activity
   * @param drawerLayout DrawerLayout
   */
  public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
      return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {
      activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    // 内容布局不是 LinearLayout 时,设置padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
      contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
    }

    // 设置属性
    ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
    drawerLayout.setFitsSystemWindows(false);
    contentLayout.setFitsSystemWindows(false);
    contentLayout.setClipToPadding(true);
    drawer.setFitsSystemWindows(false);
  }
Example #2
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();
    Fragment fragment = null;
    Class fragmentClass = null;

    if (id == R.id.nav_map) {
      FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
      fragmentTransaction.remove(mapFragment);
      fragmentTransaction.add(R.id.main_bar_view, mapFragment);
      fragmentTransaction.commit();

    } else if (id == R.id.nav_list) {
      FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
      fragmentTransaction.remove(listFragment);
      fragmentTransaction.add(R.id.main_bar_view, listFragment);
      fragmentTransaction.commit();
    } else if (id == R.id.nav_supplies) {

    } else if (id == R.id.nav_yields) {

    } else if (id == R.id.nav_settings) {

    } else if (id == R.id.nav_share) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Example #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_page);
    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);
  }
Example #4
0
 /** Checks whether or not any drawer is open in the DrawerActivity. */
 public final boolean isDrawerOpen() {
   DrawerLayout drawer = getDrawerLayout();
   return drawer != null
       && (drawer.isDrawerOpen(Gravity.START)
           || drawer.isDrawerOpen(Gravity.LEFT)
           || drawer.isDrawerOpen(Gravity.RIGHT));
 }
  @Override
  public void setListener(final Listener listener) {
    if (listener == null) {
      drawerLayout.setDrawerListener(null);
    } else {
      drawerLayout.setDrawerListener(
          new DrawerLayout.DrawerListener() {
            @Override
            public void onDrawerSlide(View view, float v) {}

            @Override
            public void onDrawerOpened(View view) {
              listener.onDrawerOpened(view);
            }

            @Override
            public void onDrawerClosed(View view) {
              listener.onDrawerClosed(view);
            }

            @Override
            public void onDrawerStateChanged(int i) {}
          });
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    HistoryFragment fragment = new HistoryFragment();
    android.support.v4.app.FragmentTransaction fragmentTransaction =
        getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(R.id.fragment_container, fragment);
    fragmentTransaction.commit();

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    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) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
  }
Example #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // ROTAZIONE SCHERMO BLOCCATA
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    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);

    viewPager = (ViewPager) findViewById(R.id.viewpagerHome);
    setupViewPager(viewPager);

    tabLayout = (TabLayout) findViewById(R.id.tabsHome);
    tabLayout.setupWithViewPager(viewPager);

    setTitle("Home");
  }
Example #8
0
 public void setOpen(boolean isOpen) {
   if (isOpen) {
     drawerLayout.openDrawer(GravityCompat.START);
   } else {
     drawerLayout.closeDrawer(GravityCompat.START);
   }
 }
Example #9
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_search) {
      // Handle the camera action
      Intent i = new Intent(this, ListaProductos.class);
      startActivity(i);
    } else if (id == R.id.nav_categories) {
      // Desplegar las 4 categorias: cafes, frutas, refrescos, snacks
    } else if (id == R.id.nav_filter) {
      Intent i2 = new Intent(this, SelectFilters.class);
      startActivity(i2);
    } else if (id == R.id.nav_contact) {
      // Hacer cosas chungas con la app de correo
    } else if (id == R.id.nav_setting) {
      Intent i3 = new Intent(this, Settings.class);
      startActivity(i3);
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Example #10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //        setContentView(R.layout.activity_resource);
    LayoutInflater inflater =
        (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View contentView = inflater.inflate(R.layout.activity_resource, null, false);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.addView(contentView, 0);

    arrayList.add("Resource");
    arrayList.add("Resource");
    arrayList.add("Resource");
    arrayList.add("Resource");

    ListView list_View = (ListView) this.findViewById(R.id.resource_listView);

    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, arrayList);
    list_View.setAdapter(adapter);

    /*list_View.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Intent edit_doc = new Intent(ItTickets.this,Edit_document.class);
            startActivity(edit_doc);

        }
    });*/
  }
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_us) {
      // Handle the camera action
      mwebView.loadUrl("http://www.newsweek.com/us");
    } else if (id == R.id.nav_world) {
      mwebView.loadUrl("http://www.newsweek.com/world");
    } else if (id == R.id.nav_tech) {
      mwebView.loadUrl("http://www.newsweek.com/tech-science");
    } else if (id == R.id.nav_sports) {
      mwebView.loadUrl("http://www.newsweek.com/sports");
    } else if (id == R.id.nav_share) {
      mwebView.loadUrl("http://www.newsweek.com/about-newsweek");
    } else if (id == R.id.nav_send) {
      mwebView.loadUrl("http://www.newsweek.com/contact");
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Example #12
0
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    int id = item.getItemId();

    Intent intent;
    switch (id) {
      case R.id.nav_test1:
        intent = new Intent(this, MovieActivity.class);
        startActivity(intent);
        break;
      case R.id.nav_test2:
        intent = new Intent(this, PalindromeActivity.class);
        startActivity(intent);
        break;
      case R.id.nav_test3:
        intent = new Intent(this, BluetoothActivity.class);
        startActivity(intent);
        break;
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);

    return true;
  }
Example #13
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    switch (item.getItemId()) {
      case R.id.navView_zekrs:
        emptyFragmentStack();
        getFragmentManager()
            .beginTransaction()
            .replace(R.id.mainContainer, new ZekrListFragment())
            .commit();
        break;
      case R.id.nav_gallery:
        break;
      case R.id.nav_slideshow:
        break;
      case R.id.navView_settings:
        break;
      case R.id.nav_share:
        break;
      case R.id.nav_send:
        break;
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
  public void setUp(int fragmentId, final DrawerLayout drawerLayout) {
    fragmentContainerView = baseActivity.findViewById(fragmentId);
    this.drawerLayout = drawerLayout;

    drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    ActionBar actionBar = baseActivity.getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    drawerToggle =
        new QMActionBarDrawerToggle(
            baseActivity,
            drawerLayout,
            R.drawable.ic_drawer,
            R.string.nvd_open,
            R.string.nvd_close);

    if (!userLearnedDrawer && !fromSavedInstanceState) {
      drawerLayout.openDrawer(fragmentContainerView);
    }

    drawerLayout.post(
        new Runnable() {
          @Override
          public void run() {
            drawerToggle.syncState();
          }
        });

    drawerLayout.setDrawerListener(drawerToggle);
  }
Example #15
0
  public void setUp(int fragmentId, DrawerLayout drawerLayout, final Toolbar toolbar) {
    containerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;
    mDrawerToggle =
        new ActionBarDrawerToggle(
            getActivity(), drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
          @Override
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            getActivity().invalidateOptionsMenu();
          }

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

          @Override
          public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            toolbar.setAlpha(1 - slideOffset / 2);
          }
        };

    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerLayout.post(
        new Runnable() {
          @Override
          public void run() {
            mDrawerToggle.syncState();
          }
        });
  }
Example #16
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.log_in) {
      Intent i = new Intent(MainActivity.this, login.class);
      startActivity(i);
      // Handle the camera action
    } else if (id == R.id.nav_gallery) {

    } else if (id == R.id.nav_manage) {

    } else if (id == R.id.nav_share) {

    } else if (id == R.id.devInfo) {
      Intent j = new Intent(MainActivity.this, DevInfo.class);
      startActivity(j);
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Example #17
0
  private void initToolBar() {
    toolbar.setTitleTextColor(Color.parseColor("#ffffff")); // 设置标题颜色
    toolbar.setLogo(R.mipmap.ic_launcher);
    setSupportActionBar(toolbar);

    //        getSupportActionBar().setDisplayHomeAsUpEnabled(true);//返回键是否显示
    //        getSupportActionBar().setHomeButtonEnabled(true);//应用图标是否可以点击,此api在toolbar中好像没有效果,待验证
    //        getSupportActionBar().setDisplayShowHomeEnabled(true);//应用图标是否显示
    mDrawerToggle =
        new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open, R.string.close) {
          @Override
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            //                mAnimationDrawable.stop();
          }

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

    mDrawerToggle.syncState();
    drawerLayout.setDrawerListener(mDrawerToggle);

    drawerLayout.setDrawerShadow(R.drawable.navigation_drawer_shadow, GravityCompat.START);
    //        drawerLayout.setDrawerListener(openDrawerListener);

  }
  public void setUp(DrawerLayout drawerLayout, final Toolbar toolbar, int id) {
    viewContainer = getActivity().findViewById(id);
    this.toolbar = toolbar;
    this.drawerLayout = drawerLayout;
    actionBarDrawerToggle =
        new ActionBarDrawerToggle(
            getActivity(), this.drawerLayout, toolbar, R.string.open, R.string.close) {
          @Override
          public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            getActivity().invalidateOptionsMenu();
          }

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

          @Override
          public void onDrawerSlide(View drawerView, float slideOffset) {}
        };
    drawerLayout.post(
        new Runnable() {
          @Override
          public void run() {
            actionBarDrawerToggle.syncState();
          }
        });
    drawerLayout.setDrawerListener(actionBarDrawerToggle);
  }
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camera) {
      Intent intent = new Intent(this, GameActivity.class);
      startActivity(intent);
    } else if (id == R.id.nav_gallery) {
      Intent intent = new Intent(this, AlphabetActivity.class);
      startActivity(intent);
    } else if (id == R.id.nav_slideshow) {
      Intent intent = new Intent(this, PathRendererActivity.class);
      startActivity(intent);
    } else if (id == R.id.nav_manage) {
      Intent intent = new Intent(this, GestureActivity.class);
      startActivity(intent);
    } else if (id == R.id.nav_share) {

    } else if (id == R.id.nav_send) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Example #20
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camara) {
      // Handle the camera action
    } else if (id == R.id.nav_gallery) {

    } else if (id == R.id.nav_slideshow) {

    } else if (id == R.id.nav_manage1) {

    } else if (id == R.id.nav_manage2) {

    } else if (id == R.id.nav_manage3) {

    } else if (id == R.id.nav_manage4) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Example #21
0
  @Override
  public void onBackPressed() {
    if (mDrawer.isDrawerOpen(GravityCompat.START)) {
      mDrawer.closeDrawer(GravityCompat.START);
      return;
    }

    // handle back button for all fragment
    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame);
    if (fragment instanceof FavoriteBoardFragment) {
      if (!favoriteBoardFragment.atFavoriteRoot()) {
        favoriteBoardFragment.popFavoritePath();
        favoriteBoardFragment.RefreshFavoriteBoards();
        return;
      }
    }

    if (fragment != hotTopicFragment) {
      // return to hottopic if we are not there yet
      String title = "首页导读";
      FragmentManager fm = getSupportFragmentManager();
      fm.beginTransaction().replace(R.id.content_frame, hotTopicFragment).commit();
      setTitle(SMTHApplication.App_Title_Prefix + title);
      return;
    }

    // for other cases, double back to exit app
    DoubleBackToExit();
  }
  public void startMetrialView() {
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);

    dlDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    dtToggle = new ActionBarDrawerToggle(this, dlDrawer, R.string.app_name, R.string.hello_world);
    dlDrawer.setDrawerListener(dtToggle);
    pager = (ViewPager) findViewById(R.id.pager);
    adapter = new ViewPagerAdapter_1(getSupportFragmentManager(), Titles);
    pager.setAdapter(adapter);

    tabs = (SlidingTabLayout) findViewById(R.id.tabs);
    tabs.setDistributeEvenly(true);
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {

          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.tabsScrollColor);
          }
        });
    tabs.setViewPager(pager);
    ChoiceStartAlarmMenu choiceStartAlarmMenu = new ChoiceStartAlarmMenu(this);
    drawer = (FrameLayout) findViewById(R.id.drawer);
    drawer.addView(choiceStartAlarmMenu);
    //        dlDrawer.closeDrawer(dtToggle);
    dlDrawer.closeDrawer(drawer);
  }
Example #23
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (mDrawerToggle != null && mDrawerToggle.onOptionsItemSelected(item)) return true;

    if (android.R.id.home == item.getItemId()) {
      if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) mDrawerLayout.closeDrawers();
      else mDrawerLayout.openDrawer(GravityCompat.START);

      return true;
    }

    // 关于
    if (item.getItemId() == R.id.about) AboutWebFragment.launchAbout(this);
    // 意见反馈
    else if (item.getItemId() == R.id.feedback) PublishActivity.publishFeedback(this);
    // 好友分组
    else if (item.getItemId() == R.id.friendGroups) GroupSortFragment.lanuch(this);
    // 搜索用户或者微博
    //        else if (item.getItemId() == R.id.search)
    //            SearchActivity.launch(this);
    // 退出
    else if (item.getItemId() == R.id.exitapp) finish();
    // 新微博
    else if (item.getItemId() == R.id.publish) PublishActivity.publishStatus(this, null);
    // 搜人
    else if (item.getItemId() == R.id.search_user) SearchUserFragment.launch(this);
    // 搜微博
    else if (item.getItemId() == R.id.search_status) SearchTopicsFragment.launch(this);
    // 开始离线
    else if (item.getItemId() == R.id.toggle_offline) OfflineUtils.toggleOffline(this);

    return super.onOptionsItemSelected(item);
  }
 public void toggleDrawer() {
   if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
     mDrawerLayout.closeDrawer(Gravity.RIGHT);
   } else {
     mDrawerLayout.openDrawer(Gravity.RIGHT);
   }
 }
Example #25
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camara) {
      // Handle the camera action
    } else if (id == R.id.nav_gallery) {

      Toast.makeText(getApplicationContext(), "Galeria", Toast.LENGTH_SHORT).show();

    } else if (id == R.id.nav_slideshow) {

      Toast.makeText(getApplicationContext(), "Slideshow", Toast.LENGTH_SHORT).show();

    } else if (id == R.id.nav_manage) {

      Toast.makeText(getApplicationContext(), "Manage", Toast.LENGTH_SHORT).show();

    } else if (id == R.id.nav_share) {

      Toast.makeText(getApplicationContext(), "Share", Toast.LENGTH_SHORT).show();

    } else if (id == R.id.nav_send) {

      Toast.makeText(getApplicationContext(), "Send", Toast.LENGTH_SHORT).show();
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  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
      displayView(0);
    } else if (id == R.id.nav_profile) {
      displayView(1);
    } else if (id == R.id.nav_earn_pts) {
      displayView(2);
    } else if (id == R.id.nav_top_10_day) {
      displayView(3);
    } else if (id == R.id.nav_history) {
      displayView(4);
    } else if (id == R.id.nav_feedback) {
      displayView(5);
    } else if (id == R.id.nav_about) {
      displayView(6);
    } else if (id == R.id.nav_logout) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Example #27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_start);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    this.setTitle(R.string.title_activity_start);

    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);

    checkSD();
  }
 @Override
 public boolean onNavigationItemSelected(MenuItem item) {
   int id = item.getItemId();
   switch (id) {
     case R.id.nav_new:
       break;
     case R.id.nav_xingan:
       break;
     case R.id.nav_mr:
       break;
     case R.id.nav_sw:
       break;
     case R.id.nav_xz:
       break;
     case R.id.nav_wallpaper:
       break;
     case R.id.nav_share:
       break;
     case R.id.nav_personal:
       break;
   }
   toolbar.setTitle(item.getTitle());
   DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
   drawer.closeDrawer(GravityCompat.START);
   return true;
 }
Example #29
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camara) {
      // Handle the camera action
      Intent intent = new Intent(MainActivity.this, DetailActivity.class);
      startActivity(intent);
      item.setChecked(false);
    } else if (id == R.id.nav_gallery) {
      Intent intent = new Intent(MainActivity.this, RoutinNaviActivity.class);
      startActivity(intent);
      item.setChecked(false);
    } else if (id == R.id.nav_share) {

    } else if (id == R.id.nav_send) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Example #30
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_top_book) {
      Intent topBook = new Intent(getApplicationContext(), MainActivity.class);
      startActivity(topBook);
    } else if (id == R.id.nav_new_book) {
      Intent newBook = new Intent(getApplicationContext(), NewBook.class);
      startActivity(newBook);
    } else if (id == R.id.nav_search) {
      Intent search = new Intent(getApplicationContext(), Search.class);
      startActivity(search);
    } else if (id == R.id.nav_setting) {
      Toast.makeText(getApplicationContext(), getString(R.string.setting), Toast.LENGTH_SHORT)
          .show();
    } else if (id == R.id.nav_about_us) {
      Toast.makeText(getApplicationContext(), getString(R.string.about_us), Toast.LENGTH_SHORT)
          .show();
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }