How can I reject the navigation box to use the Back-home-icon button?

I also use the action bar with the search bar, and I need to use the ActionBar ico as the back button:

enter image description here

But I also use the navigation box ... How can I remove / hide / disable the navigation box menu to use the back button?

My ActionBar Code:

@Override public boolean onCreateOptionsMenu(Menu menu){ MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); this.getSupportActionBar().setDisplayShowCustomEnabled(true); this.getSupportActionBar().setDisplayShowTitleEnabled(false); this.getSupportActionBar().setDisplayHomeAsUpEnabled(true); this.getSupportActionBar().setHomeButtonEnabled(true); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v; if(!searchView){ v = inflator.inflate(R.layout.action_textview, null); ((TextView) v.findViewById(R.id.titleText)).setText(actionTitle); menu.getItem(0).setVisible(true); menu.getItem(2).setVisible(true); mainMenu = menu; }else{ v = inflator.inflate(R.layout.action_searchview, null); actionSearch = (EditText) v.findViewById(R.id.searchText); actionSearch.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { int result = actionId & EditorInfo.IME_MASK_ACTION; switch(result) { case EditorInfo.IME_ACTION_DONE: case EditorInfo.IME_ACTION_NEXT: case EditorInfo.IME_ACTION_GO: case 0: ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(actionSearch.getWindowToken(), 0); String temp = actionSearch.getText().toString(); searchFor(temp); break; } return true; } }); actionSearch.requestFocus(); menu.getItem(0).setVisible(false); menu.getItem(2).setVisible(false); } this.getSupportActionBar().setCustomView(v); return super.onCreateOptionsMenu(menu); } 

Code Reference:

  • My Title is a custom view with only TextView to adjust the color and font size; (action_textview)
  • My SearchBar uses a custom view only with EditText; (Action_searchview)
+8
android android-actionbar navigation back
source share
1 answer

In ActionBarDrawerToggle you can use the setDrawerIndicatorEnabled(Boolean enable) method. In addition, you can set the ActionBar Display parameters. In particular, the flag DISPLAY_HOME_AS_UP . Link to documents

Then handle the click event as usual.

+11
source share

All Articles