There is an activation with the driver, when the application starts, the first fragment starts from the driver. It displays foliage, when you click on an element of foliage

private void openFragmentMineral(String mineral) { ScaleFragmentMineral fScaleFragmentMineral = new ScaleFragmentMineral(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.mainFrame, fScaleFragmentMineral); Bundle bundle = new Bundle(); bundle.putString(KEY_MIN, mineral); fScaleFragmentMineral.setArguments(bundle); fragmentTransaction.commit(); } 

a fragment opens

 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { myView = inflater.inflate(R.layout.fragment_scale_mineral, container, false); // получаем значение Bundle bundle = getArguments(); if (bundle != null) { strNameMineral = bundle.getString(KEY_MIN); if (strNameMineral != null) { // меняем заголовок тулбара ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(strNameMineral); } } return myView; } 

here in it, instead of the back button (return to the parent fragment with foliage), the driver menu button is shown. The question is actually how to remove the driver menu button and instead put the arrow back?

    1 answer 1

    It should be something like this:

     ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); 

    And, having received the link to ActionBarDrawerToggle , which is needed for the work of the drover, call

     mDrawerToggle.setDrawerIndicatorEnabled(false); 
    • Thank! Only in my case, it was necessary to first disable the driver, and then add the button - Maxim Fomichev
    • I do not even know whether to create a new topic or better yet here. Help catch a button click. I tried a bunch of options from the Internet, it does not respond to any buttons. - Maxim Fomichev
    • @MaximFomichev, it is necessary to catch in onOptionsItemSelected . ID - android.R.id.home - JuriySPb
    • if you are @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Log.i(LOG_TAG, "нажали кнопку назад"); return true; } return super.onOptionsItemSelected(item); } about this @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Log.i(LOG_TAG, "нажали кнопку назад"); return true; } return super.onOptionsItemSelected(item); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Log.i(LOG_TAG, "нажали кнопку назад"); return true; } return super.onOptionsItemSelected(item); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Log.i(LOG_TAG, "нажали кнопку назад"); return true; } return super.onOptionsItemSelected(item); } then it does not work - Maxim Fomichev
    • @MaximFomichyov, does not work, perhaps, just because you somehow "turned off" the drover ... Ask, perhaps, just a separate question describing the problem. - Yuriy SPb