toolbair.setNavigationOnClickListener não está funcionando

toolbair.setNavigationOnClickListener esta function não está funcionando, não tem idéia do porquê.

layout activity_main.xml

  • prompt de senha no android
  • Como detectair memory leaks
  • Android Picasso gira automaticamente a image
  • android: layout_weight = "33" como é que ido-> visível visível-> ido afetou isso?
  • Implementando resources USSD. Encadernando um service ao PhoneUtils sem reiniciair o telefone em todas as atualizações
  • Falha ao resolview: android.airch.lifecycle: extensões: 1.0.0-alpha1 android studio 3.0
  • <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" android:fitsSystemWindows="true" tools:context=".login.LoginActivity"> <android.support.design.widget.AppBairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBairOviewlay"> <android.support.v7.widget.Toolbair android:id="@+id/toolbair" android:layout_width="match_pairent" android:layout_height="?attr/actionBairSize" android:background="?attr/colorPrimairy" app:popupTheme="@style/AppTheme.PopupOviewlay"> </android.support.v7.widget.Toolbair> </android.support.design.widget.AppBairLayout> <include layout="@layout/content_main" /> 

    container_main.xml Layout

     <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:fitsSystemWindows="true"> <FrameLayout android:id="@+id/frame_container" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <!-- Listview to display slider menu --> <ListView android:id="@+id/list_slidermenu" android:layout_width="240dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:background="@color/list_background" android:choiceMode="singleChoice" android:divider="@color/list_divider" android:dividerHeight="1dp" android:listSelector="@drawable/list_selector" /> </android.support.v4.widget.DrawerLayout> 

    Classe de atividade Java

     import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } } import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } } import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } } import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } }; import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } } import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } }); import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } } import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } } import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } } import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } } import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } } import android.app.Fragment; import android.app.FragmentManager; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v7.app.ActionBairDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbair; import android.util.Log; import android.view.View; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; // slide menu items private String[] navMenuTitles; private TypedArray navMenuIcons; private ArrayList<NavDrawerItem> navDrawerItems; private NavDrawerListAdapter adapter; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // enabling action bair app icon and behaving it as toggle button Toolbair toolbair = (Toolbair)findViewById(R.id.toolbair); toolbair.setNavigationIcon(R.drawable.ic_drawer); setSupportActionBair(toolbair); // load slide menu items navMenuTitles = getResources().getStringArray(R.airray.nav_drawer_items); // nav drawer icons from resources navMenuIcons = getResources() .obtainTypedArray(R.airray.nav_drawer_icons); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); navDrawerItems = new ArrayList<>(); // adding nav drawer items to airray // Home navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1))); // Find People navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1))); // Photos navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1))); // Communities, Will add a counter here navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1))); // Recycle the typed airray navMenuIcons.recycle(); // setting the nav drawer list adapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems); mDrawerList.setAdapter(adapter); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, toolbair, R.string.app_name, R.string.app_name ){ public void onDrawerClosed(View view) { //getActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { //getActionBair().setTitle(mDrawerTitle); // calling onPrepaireOptionsMenu() to hide action bair icons invalidateOptionsMenu(); } @Oviewride public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); } }; mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("COMECOU", "COMECOU"); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { // on first time display view for first nav item displayView(0); } } /** * Displaying fragment view for selected nav drawer list item * */ private void displayView(int position) { // update the main content by replacing fragments Fragment fragment = null; switch (position) { case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; case 2: fragment = new PhotosFragment(); break; case 3: fragment = new CommunityFragment(); break; case 4: fragment = new PagesFragment(); break; case 5: fragment = new WhatsHotFragment(); break; default: break; } if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.frame_container, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); setTitle(navMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } else { // error in creating fragment Log.e("MainActivity", "Error in creating fragment"); } } } 

    Eu esqueci de dizer que se eu deslizair, eu posso view o menu é que apenas os botões não estão sendo registrados.

    ATUALIZAR

    Por favor, veja a minha resposta se quiser saber como resolvê-la.

  • Android Studio faz meu module de teste depender do module de aplicação
  • Quando usair getShairedPreferences vs savedInstanceState?
  • Como abrir ou simulair um click uma preference do Android, criada com XML, por meio de programação?
  • Como Inflair uma exibição em expansão com uma visão de relação de aspecto fixa
  • AppWidget: a instância não é exibida após a atividade de configuration estair concluída em alguns dispositivos
  • Obter APK do aplicativo instalado
  • 4 Solutions collect form web for “toolbair.setNavigationOnClickListener não está funcionando”

    Outra coisa a lembrair é que

    ligando

    toolbair.setNavigationOnClickListener()

    antes

    setSupportActionBair(toolbair);

    não vai funcionair.

    Eu vejo que você está usando o ActionBairDrawerToggle e, portanto, setNavigationOnClickListener() é o errado. O setToolbairNavigationClickListener() certo é setToolbairNavigationClickListener() . Isso fairá com que ele se comporte como um button alternativo.

     mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("TOU AQUI", "TOU AQUI"); } }); } mDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("TOU AQUI", "TOU AQUI"); } }); 

    Eu findi o erro que não podemos colocair a bairra de ferramentas fora do DrawerLayout

    Aqui está como pairece:

     <?xml viewsion="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent"> <android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:fitsSystemWindows="true"> <FrameLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <!-- Framelayout to display Fragments --> <FrameLayout android:id="@+id/frame_container" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <android.support.v7.widget.Toolbair android:id="@+id/toolbair" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="#2196F3" android:minHeight="?attr/actionBairSize"/> </FrameLayout> <!-- Listview to display slider menu --> <ListView android:id="@+id/list_slidermenu" android:layout_width="240dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:background="@color/list_background" android:choiceMode="singleChoice" android:divider="@color/list_divider" android:dividerHeight="1dp" android:listSelector="@drawable/list_selector" /> </android.support.v4.widget.DrawerLayout> </FrameLayout> 

    Você deve usair o ActionBairDrawerToggle#setToolbairNavigationClickListener no seu caso.

    Da documentation do Android:

    Quando DrawerToggle é construído com uma Bairra de Ferramentas, ele define o ouvinte de clique no ícone de Navegação. Se quiser ouvir cliques no ícone de Navegação quando DrawerToggle estiview desativado (setDrawerIndicatorEnabled (boolean), você deve chamair esse método com o seu ouvinte e DrawerToggle encaminhairá os events de clique paira esse ouvinte quando o indicador da gaveta estiview desativado.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.