【问题标题】:RecyclerView 's talkback function not wellRecyclerView 的对讲功能不好
【发布时间】:2015-03-08 04:25:27
【问题描述】:

我现在正在使用 RecyclerView 而不是 ListView 来构建一个旨在帮助盲人的 Android 应用程序。

问题是当我启动对讲功能时,阅读器一个一个地阅读列表,我无法通过手势控制阅读器跳转到下一个或前一个项目。我能做的就是等待读者到达我需要的那个。我的测试手机是三星 S4。

根据我同事的经验,对讲功能在普通ListView上配合手势效果很好。

现在我只是想知道这是 RecyclerView API 中的错误吗?还是设置或代码有问题?

无论如何,我会继续测试它。

【问题讨论】:

    标签: android listview android-recyclerview talkback


    【解决方案1】:

    这是因为recyclerView作为ViewGroup获得焦点,而列表中的item没有获得焦点。

    所以在 ViewHolder 的布局 xml 文件中,将 focusable 属性设置为 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">
    

    如果问题仍然存在,请在 Fragment 中尝试:

    mRecyclerView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    

    【讨论】:

      【解决方案2】:

      我通过设置解决了这个问题

      android:clickable="true"

      到布局中的元素( textviews ),在我的情况下它工作得很好。

      【讨论】:

        猜你喜欢
        • 2019-01-14
        • 1970-01-01
        • 1970-01-01
        • 2013-11-28
        • 2017-09-13
        • 1970-01-01
        • 1970-01-01
        • 2012-07-28
        • 2023-03-22
        相关资源
        最近更新 更多