Search code examples
androidlistviewandroid-recyclerviewtalkback

RecyclerView 's talkback function not well


I am now using RecyclerView instead of ListView to build a android app aiming at assisting blind people.

The problem is when I start the talkback function, The reader read the list one by one, where I can't control the reader jump to next or the former item by my gesture. What I can do is wait the reader until it reach the one I need. My test phone is Samsung S4.

According to my colleague's experience, the talkback function works well with gesture on the normal ListView.

Now I just wonder is it a bug in RecyclerView API? or there is something wrong with the settings or the codes?

Anyway, I will continuing testing it.


Solution

  • This is because the recyclerView is focused as a ViewGroup, while the items in the list do not get the focus.

    So in the layout xml file for the ViewHolder, set the focusable attribute to true.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        style="@style/ItemInView">
    

    If the the problem still exist, try this in your Fragment:

    mRecyclerView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);