How to modify the Action Drawer of Navigation Drawer Activity?

0

We can say that I have the same thing that Android Studio itself adds by default, its layouts, its activities etc ... But I would like to modify the ActionBar that adds me by default, and I can not find anywhere where the configuration is. of the actionbar.

Could someone please help me modify this section or at least help me locate it in XML's or Java's?

    
asked by DazzelWazzel 07.05.2018 в 17:48
source

2 answers

0

If you need to edit the ActionBar text, do it in the following way:

  

manifests-> AndroidManifest.xml

    <activity
        android:name=".MainActivity"
        android:label="Texto que se mostrará en el actionBar" />
  • To edit browser content:
  

res-> layout- > nav_header_main.xml

  • To add or edit browser menus:
  

res-> menu- > activity_main_drawer.xml

You can create groups and within this, items that will be the menus that will be displayed.

For example:

<group android:checkableBehavior="single">
    <item
        android:id="@+id/nav_home"
        android:title="@string/home" />

    <item
        android:id="@+id/nav_register"
        android:title="@string/register_nav" />

    <item
        android:id="@+id/nav_foods"
        android:title="@string/food" />
</group>

To modify the content of the activity:

  

res-> layout- > content_main.xml

For more information: Creating a navigation side panel

    
answered by 07.05.2018 в 22:51
0

Well finally I have been able to solve it, in this link they solve it in previous versions and some do not work but the one that proposes to create a custom Drawable from the code and then measure it to the ActionBarToggle itself dedse the code is the best solution.

//////HAMBURUGESA//////
    //Nos creamos nuestro Icono drawable personalizado
    Drawable burger = ResourcesCompat.getDrawable(getResources(), R.mipmap.cart_icon_pink_round, this.getTheme()); //Le pasamos el mipmap pero estamos creando drwaable no nos da problemas de momento
    //Instanciamos el Layout del Drawer
    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    //Instanciamos y construimos el ActionBarDrawerToggle
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    toggle.setDrawerIndicatorEnabled(false);// Hay que decirle que deshabilite el burger actual
    toggle.setHomeAsUpIndicator(burger); //Le indico cual va a ser el Drawable que utilizará para sacar y meter el navigator
    //Creamos un listener especial él.
    toggle.setToolbarNavigationClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (drawer.isDrawerVisible(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            } else {
                drawer.openDrawer(GravityCompat.START);
            }
        }
    });


    toggle.syncState();
    ////FIN HAMBURGUESA ////

I also leave here the reference link where I finally clarified all my doubts, in case someone is curious or has the same problem in the future. Greetings and thanks to all who participated. link

    
answered by 08.05.2018 в 12:44