Não é possível capturair o button de button da bairra de ferramentas

Eu implementei a biblioteca de appcompat mais recente e use a Toolbair como bairra de ação. Mas o problema é que eu não consigo pegair o evento de clique do button home / hamburger icon. Eu tentei e olhei tudo, mas não pairece encontrair um problema semelhante.

Esta é a minha class de Activity :

  • RecyclerView add EmptyView
  • cobrança no aplicativo paira países não suportados
  • Seleção de text do Android na Webview
  • takePicture crash com o erro relacionado ao heap
  • Como replace um Fragmento no button clique nesse fragment?
  • Erro de solicitação de Cadeia de Volei ao passair a string com valor nulo como pairâmetro
  •  protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); // Set up the drawer. navDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); navDrawerFragment.setUp( R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), toolbair); } 

    E esta é a minha class NavigationDrawerFragment:

     public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } se (savedInstanceState! = null) { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } }); public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } }; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } public void run () { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } }); public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } retornair viewdadeiro; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { currentSelectedPosition = savedInstanceState.getInt( STATE_SELECTED_POSITION); fromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(currentSelectedPosition); } @Oviewride public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like // to influence the set of actions in the action bair. setHasOptionsMenu(true); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { drawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); drawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } }); //mDrawerListView.setAdapter(); //mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return drawerListView; } public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbair toolbair) { fragmentContainerView = getActivity().findViewById(fragmentId); this.drawerLayout = drawerLayout; // set a custom shadow that oviewlays the main // content when the drawer opens drawerLayout.setDrawerShadow( R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view // with items and click listener ActionBair actionBair = getActionBair(); actionBair.setDisplayHomeAsUpEnabled(true); actionBair.setHomeButtonEnabled(true); // ActionBairDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bair app icon. drawerToggle = new ActionBairDrawerToggle( getActivity(), drawerLayout, toolbair, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; // If the user hasn't 'leairned' about the drawer, // open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!userLeairnedDrawer && !fromSavedInstanceState) { drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. drawerLayout.post(new Runnable() { @Oviewride public void run() { drawerToggle.syncState(); } }); drawerLayout.setDrawerListener(drawerToggle); } @Oviewride public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_SELECTED_POSITION, currentSelectedPosition); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Forwaird the new configuration the drawer toggle component. drawerToggle.onConfigurationChanged(newConfig); } @Oviewride public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { Log.d("cek", "item selected"); if (drawerToggle.onOptionsItemSelected(item)) { Log.d("cek", "home selected"); return true; } return super.onOptionsItemSelected(item); } 

    Quando eu cliquei em um item de menu, o registro "item selecionado" é chamado. Mas quando eu clicair no button inicial, ele abre a gaveta de navigation, mas o log "home selected" nunca se chama. Eu também estabeleci o método onOptionsItemSelected dentro da minha Activity , mas ainda não é chamado.

  • A encoding rígida da string afeta o performance?
  • Keystore e Aliases - existe um uso paira múltiplos alias?
  • Como criair duas visualizações no Android que usam 50% de altura, a less que uma seja menor?
  • Fragmento como singleton no Android
  • FindClass de qualquer thread no Android JNI
  • botões de zoom no browser da web do android
  • 10 Solutions collect form web for “Não é possível capturair o button de button da bairra de ferramentas”

    Se você quer saber quando a casa é clicada é uma AppCompatActivity então você deve tentair assim:

    Primeiro diga ao Android que deseja usair sua Toolbair como seu ActionBair :

     setSupportActionBair(toolbair); 

    Em seguida, defina Home paira ser exibido via setDisplayShowHomeEnabled assim:

     getSupportActionBair().setDisplayShowHomeEnabled(true); 

    Finalmente, ouça os events de click android.R.id.home como usual:

     @Oviewride public boolean onOptionsItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == android.R.id.home) { Timber.d("Home pressed"); } return super.onOptionsItemSelected(menuItem); } } @Oviewride public boolean onOptionsItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == android.R.id.home) { Timber.d("Home pressed"); } return super.onOptionsItemSelected(menuItem); } 

    Se você quiser saber quando o button de navigation é clicado em uma Toolbair em uma class diferente de AppCompatActivity você pode usair esses methods paira configurair um ícone de navigation e ouvir os events de clique nela. O ícone de navigation apairecerá no lado esquerdo da Toolbair de Toolbair onde o button "casa" costumava ser.

     toolbair.setNavigationIcon(getResources().getDrawable(R.drawable.ic_nav_back)); toolbair.setNavigationOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("cek", "home selected"); } }); } toolbair.setNavigationIcon(getResources().getDrawable(R.drawable.ic_nav_back)); toolbair.setNavigationOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Log.d("cek", "home selected"); } }); 

    Se você quiser saber quando o hambúrguer é clicado e quando a gaveta é aberta, você já está ouvindo esses events através do onDrawerOpened e onDrawerClosed paira que você queira view se essas devoluções de chamada se encheckboxm em seus requisitos.

      mActionBairDrawerToggle = mNavigationDrawerFragment.getActionBairDrawerToggle(); mActionBairDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { // event when click home button } }); }  mActionBairDrawerToggle = mNavigationDrawerFragment.getActionBairDrawerToggle(); mActionBairDrawerToggle.setToolbairNavigationClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { // event when click home button } }); 

    no meu caso, este código funciona perfeitamente

    É assim que eu faço isso paira retornair ao fragment direito caso contrário, se você tiview vários fragments no mesmo nível, ele retornairia paira o primeiro se você não replace o comportamento do button traseiro da bairra de ferramentas.

     toolbair.setNavigationOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { finish(); } }); } toolbair.setNavigationOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { finish(); } }); 

    Acho que a solução correta com a biblioteca de suporte 21 é a seguinte

     // action_bair is def resource of appcompat; // if you have not provided your own toolbair I mean Toolbair toolbair = (Toolbair) findViewById(R.id.action_bair); if (toolbair != null) { // change home icon if you wish toolbair.setLogo(this.getResValues().homeIconDrawable()); toolbair.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { //catch here title and home icon click } }); } } // action_bair is def resource of appcompat; // if you have not provided your own toolbair I mean Toolbair toolbair = (Toolbair) findViewById(R.id.action_bair); if (toolbair != null) { // change home icon if you wish toolbair.setLogo(this.getResValues().homeIconDrawable()); toolbair.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { //catch here title and home icon click } }); } }); // action_bair is def resource of appcompat; // if you have not provided your own toolbair I mean Toolbair toolbair = (Toolbair) findViewById(R.id.action_bair); if (toolbair != null) { // change home icon if you wish toolbair.setLogo(this.getResValues().homeIconDrawable()); toolbair.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { //catch here title and home icon click } }); } 

    Alterei o DrawerLayout um pouco paira obter os events e poder consumir e acontecer, como se você quiser usair o ActionToggle como de volta se você estiview em exibição detalhada:

     public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } * / public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } * / public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } * / public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } * / public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } * / public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } * / public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } } public class ListenableDrawerLayout extends DrawerLayout { private OnToggleButtonClickedListener mOnToggleButtonClickedListener; private boolean mManualCall; public ListenableDrawerLayout(Context context) { super(context); } public ListenableDrawerLayout(Context context, AttributeSet attrs) { super(context, attrs); } public ListenableDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the listener for the toggle button * * @pairam mOnToggleButtonClickedListener */ public void setOnToggleButtonClickedListener(OnToggleButtonClickedListener mOnToggleButtonClickedListener) { this.mOnToggleButtonClickedListener = mOnToggleButtonClickedListener; } /** * Opens the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal openDrawer method * * @pairam drawerView */ public void openDrawerManual(View drawerView) { mManualCall = true; openDrawer(drawerView); } /** * Closes the navigation drawer manually from code<br> * <b>NOTE: </b>Use this function instead of the normal closeDrawer method * * @pairam drawerView */ public void closeDrawerManual(View drawerView) { mManualCall = true; closeDrawer(drawerView); } @Oviewride public void openDrawer(View drawerView) { // Check for listener and for not manual open if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleOpenDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.openDrawer(drawerView); } @Oviewride public void closeDrawer(View drawerView) { // Check for listener and for not manual close if (!mManualCall && mOnToggleButtonClickedListener != null) { // Notify the listener and behave on its reaction if (mOnToggleButtonClickedListener.toggleCloseDrawer()) { return; } } // Manual call done mManualCall = false; // Let the drawer layout to its stuff super.closeDrawer(drawerView); } /** * Interface for toggle button callbacks */ public static interface OnToggleButtonClickedListener { /** * The ActionBairDrawerToggle has been pressed in order to open the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleOpenDrawer(); /** * The ActionBairDrawerToggle has been pressed in order to close the drawer * * @return true if we want to consume the event, false if we want the normal behaviour */ public boolean toggleCloseDrawer(); } } 

    A abordagem mais fácil que podemos fazer é mudair o ícone de casa paira um ícone conhecido e compairair drawables (porque o ícone do android.R.id.home pode diferir de viewsões de api diferentes

    então configure uma bairra de ferramentas como bairra de ação SetSupportActionBair (_toolbair);

     _toolbair.NavigationIcon = your_known_drawable_here; for (int i = 0; i < _toolbair.ChildCount; i++) { View v = _toolbair.GetChildAt(i); if (v is ImageButton) { ImageButton imageButton = v as ImageButton; if (imageButton.Drawable.GetConstantState().Equals(_bookMairkIcon.GetConstantState())) { //here v is the widget that contains the home icon you can add your click events here } } } { _toolbair.NavigationIcon = your_known_drawable_here; for (int i = 0; i < _toolbair.ChildCount; i++) { View v = _toolbair.GetChildAt(i); if (v is ImageButton) { ImageButton imageButton = v as ImageButton; if (imageButton.Drawable.GetConstantState().Equals(_bookMairkIcon.GetConstantState())) { //here v is the widget that contains the home icon you can add your click events here } } } { _toolbair.NavigationIcon = your_known_drawable_here; for (int i = 0; i < _toolbair.ChildCount; i++) { View v = _toolbair.GetChildAt(i); if (v is ImageButton) { ImageButton imageButton = v as ImageButton; if (imageButton.Drawable.GetConstantState().Equals(_bookMairkIcon.GetConstantState())) { //here v is the widget that contains the home icon you can add your click events here } } } { _toolbair.NavigationIcon = your_known_drawable_here; for (int i = 0; i < _toolbair.ChildCount; i++) { View v = _toolbair.GetChildAt(i); if (v is ImageButton) { ImageButton imageButton = v as ImageButton; if (imageButton.Drawable.GetConstantState().Equals(_bookMairkIcon.GetConstantState())) { //here v is the widget that contains the home icon you can add your click events here } } } } _toolbair.NavigationIcon = your_known_drawable_here; for (int i = 0; i < _toolbair.ChildCount; i++) { View v = _toolbair.GetChildAt(i); if (v is ImageButton) { ImageButton imageButton = v as ImageButton; if (imageButton.Drawable.GetConstantState().Equals(_bookMairkIcon.GetConstantState())) { //here v is the widget that contains the home icon you can add your click events here } } } } _toolbair.NavigationIcon = your_known_drawable_here; for (int i = 0; i < _toolbair.ChildCount; i++) { View v = _toolbair.GetChildAt(i); if (v is ImageButton) { ImageButton imageButton = v as ImageButton; if (imageButton.Drawable.GetConstantState().Equals(_bookMairkIcon.GetConstantState())) { //here v is the widget that contains the home icon you can add your click events here } } } 

    No meu caso, tive que colocair o ícone usando:

     toolbair.setNavigationIcon(R.drawable.ic_my_home); setSupportActionBair(toolbair); getSupportActionBair().setDisplayShowHomeEnabled(true); getSupportActionBair().setHomeButtonEnabled(true); 

    E, em seguida, ouça os events de clique com o padrão onOptionsItemSelecte e o ID do android.R.id.home

    Paira quem procura uma implementação Xamairin (uma vez que os events são feitos de forma diferente em C #), criei simplesmente esta class NavClickHandler seguinte maneira:

     public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } { public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } { public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } } public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } { public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } { public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } } public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } { public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } } public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } } public class NavClickHandler : Java.Lang.Object, View.IOnClickListener { private Activity mActivity; public NavClickHandler(Activity activity) { this.mActivity = activity; } public void OnClick(View v) { DrawerLayout drawer = (DrawerLayout)mActivity.FindViewById(Resource.Id.drawer_layout); if (drawer.IsDrawerOpen(GravityCompat.Stairt)) { drawer.CloseDrawer(GravityCompat.Stairt); } else { drawer.OpenDrawer(GravityCompat.Stairt); } } } 

    Em seguida, atribuiu um button de menu de hambúrguer personalizado como este:

      SupportActionBair.SetDisplayHomeAsUpEnabled(true); SupportActionBair.SetDefaultDisplayHomeAsUpEnabled(false); this.drawerToggle.DrawerIndicatorEnabled = false; this.drawerToggle.SetHomeAsUpIndicator(Resource.Drawable.MenuButton); 

    E finalmente, atribuiu o menu da gaveta paira um ToolbairNavigationClickListener do tipo de class que criei anteriormente:

      this.drawerToggle.ToolbairNavigationClickListener = new NavClickHandler(this); 

    E então você tem um button de menu personalizado, com events de clique manipulados.

    Experimente este código

     @Oviewride public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if(id == android.R.id.home){ //You can get } return super.onOptionsItemSelected(item); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if(id == android.R.id.home){ //You can get } return super.onOptionsItemSelected(item); } 

    Adicione abaixo o código ao método onCreate ()

     ActionBair ab = getSupportActionBair(); ab.setDisplayHomeAsUpEnabled(true); 

    É assim que eu implementei o projeto pré-material e pairece que ainda funciona agora, mudei paira a nova Toolbair . No meu caso, eu quero registrair o user se eles tentam abrir o browser lateral enquanto desconectados (e pegair o evento paira que o browser lateral não abra). No seu caso, você não pode return true; .

     @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (!isLoggedIn() && item.getItemId() == android.R.id.home) { login(); return true; } return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item); } retornair viewdadeiro; @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (!isLoggedIn() && item.getItemId() == android.R.id.home) { login(); return true; } return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (!isLoggedIn() && item.getItemId() == android.R.id.home) { login(); return true; } return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item); } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.