简体   繁体   中英

Android: Custom Views not giving accessibility events in a ListView

I have a ListView that has an adapter with custom views in it. The custom view extends from RelativeLayout.

This view reports accessibility events from the text correctly if it is inside another View. If I add it to a ListView or a ViewPager, all of the custom views no longer provide accessibility events when TalkBack is enabled.

Why don't my custom views work correctly inside a ListView?

It turns out that if you assign a click listener to your View that's in a ListView or a ViewPager , you stop the accessibility events from propagating to those children.

Long story short, use setOnItemSelectedListener instead of setOnClickListener .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM