-1

the Red line is under "Open navigation drawer" and "Close navigation drawer"

import androidx.appcompat.app.ActionBarDrawerToggle;
setContentView(R.layout.activity_home);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("Menu");
    setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toogle = new ActionBarDrawerToggle(this,
                drawer,
                toolbar ,
                "Open navigation drawer",
                "Close navigation drawer"

                );
        drawer.setDrawerListener(toogle);
        toogle.syncState();

This picture shows the problem

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
saad tabban
  • 285
  • 3
  • 12

2 Answers2

1

If you check constructor signature as you can see it accepts string resource, int, not String

public ActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout,
        Toolbar toolbar, @StringRes int openDrawerContentDescRes,
        @StringRes int closeDrawerContentDescRes) {
    this(activity, toolbar, drawerLayout, null, openDrawerContentDescRes,
            closeDrawerContentDescRes);
}

You need to change both from String to string resource such as R.string.YOUR_STRING that located in strings.xml file.

Thracian
  • 43,021
  • 16
  • 133
  • 222
  • Thank you very much "You need to change both from String to string resource with R.string.YOUR_STRING in strings.xml file" That's the best answer. – saad tabban Feb 10 '22 at 14:33
1

According to Android official docs openDrawerContentDescRes and closeDrawerContentDescRes are of int datatype.

ActionBarDrawerToggle (Activity activity, 
            DrawerLayout drawerLayout, 
            int openDrawerContentDescRes, 
            int closeDrawerContentDescRes)

So you need to change your string to string resource id ( R.string.YOUR_STRING) to describe the "open drawer" and "close drawer" action for accessibility.

Priyanshu
  • 101
  • 7