Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio SuppressLint "ClickableViewAccessibility" not working

In some cases I want to disable scroll on my ScrollView.
To do that I'm using .setOnTouchListener and return true in onTouch.

3.0 studio gives me lint warning that I should override performClick method also and I don't wanna do that.

When I hit alt+enter it gives me an option to supress this warning, it adds @SuppressLint("ClickableViewAccessibility") to my method.

Unfortunately, this is not working - I still see that warning.
I also tried different combinations of //noinspection, but no luck.

How can I supress this lint warning?

like image 271
Goltsev Eugene Avatar asked Nov 06 '17 09:11

Goltsev Eugene


1 Answers

I have noticed the same that neither the annotation

@SuppressLint("ClickableViewAccessibility")

nor the inline suppression

//noinspection AndroidLintClickableViewAccessibility

work reliably. The latter does suppress the warning when working in Android Studio IDE, but does not suppress it when running Lint as Gradle task.

So far the only suppression method that works both in Android Studio and with Lint Gradle task is to combine the inline suppression

//noinspection AndroidLintClickableViewAccessibility
someView.setOnTouchListener(...)

with the Lint configuration file (that works on file granularity), e.g. in build.gradle:

lintOptions {
    lintConfig file("lint.xml")
}

and in lint.xml:

<lint>
    <issue id="ClickableViewAccessibility">
        <ignore path="**/TheClassToSuppressTheWarningIn.java"/>
    </issue>
</lint>

For what it's worth, there's an issue reported and it should be fixed in Android Studio 3.1.


Update 2018-03-28: Yes, it's fixed in Android Studio 3.1.

like image 70
laalto Avatar answered Nov 20 '22 03:11

laalto