Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 734
Haven Avatar asked Mar 08 '15 04:03

Haven


2 Answers

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);
like image 165
Haven Avatar answered Nov 11 '22 14:11

Haven


I figured out this problem by setting

android:clickable="true"

to elements( textviews ) in the layout and it worked perfect in my case.

like image 44
Android Component Avatar answered Nov 11 '22 13:11

Android Component