Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android DrawerLayout - openDrawer with Gravity.Start creates a lint error "Must be one or more of..."

I have created a DrawerLayout and also have an ImageView (a 'hamburger') that opens it when clicked.
My problem is that when using the following code, a lint error is shown in AndroidStudio: Must be one or more of: Gravity.LEFT, Gravity.RIGHT..., there is no Gravity.START in there.

ImageView openDrawerImageView = findViewById(R.id.open_drawer_image_icon);
openDrawerImageView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        drawerLayout.openDrawer(Gravity.START);
    }
});
like image 753
MikeL Avatar asked Oct 24 '18 16:10

MikeL


1 Answers

I looked for a while for an answer but did not find one. I decided to leave it for later since this is only a lint error and the app actually does work with Gravity.START.
Later I needed to close the drawer in some scenario so I used: drawerLayout.closeDrawer(START) then I used the autocomplete, and got the answer: GravityCompat

drawerLayout.closeDrawer(GravityCompat.START);
like image 139
MikeL Avatar answered Sep 21 '22 18:09

MikeL