Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nav icon on Main, Sliding #9

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;

import com.saulmm.material.R;
import com.saulmm.material.fragments.HomeFragment;

Expand Down Expand Up @@ -44,6 +46,19 @@ private void initToolbar() {

Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
toolbar.inflateMenu(R.menu.menu_home);
toolbar.setNavigationIcon(R.drawable.ic_menu);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
mDrawerLayout.closeDrawer(Gravity.START);
} else {
mDrawerLayout.openDrawer(Gravity.START);
}
}
});
}

private void initNavigationView() {
Expand All @@ -56,7 +71,7 @@ private void initNavigationView() {
public boolean onOptionsItemSelected(MenuItem item) {

if (item.getItemId() == android.R.id.home) {
mDrawerLayout.openDrawer(Gravity.LEFT);
mDrawerLayout.openDrawer(Gravity.START);
return true;
}

Expand All @@ -81,6 +96,10 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
case R.id.nav_circular_sample:
startActivity(new Intent(MainActivity.this, ColorActivity.class));
break;

case R.id.nav_arrow:
startActivity(new Intent(MainActivity.this, SlidingActivity.class));
break;
}

if (nextFragment != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected void onCreate(Bundle savedInstanceState) {
}

private void configureToolbar() {
Toolbar mainToolbar = (Toolbar) findViewById(R.id.example_transition_header);
Toolbar mainToolbar = (Toolbar) findViewById(R.id.toolbar);
mainToolbar.setNavigationIcon(R.drawable.ic_menu);
setSupportActionBar(mainToolbar);
getSupportActionBar().setTitle("Sliding");

Expand Down
Binary file added app/src/main/res/drawable-xhdpi/ic_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.