gpt4 book ai didi

android - RecyclerView 的对讲功能不好

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:18:31 24 4
gpt4 key购买 nike

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

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

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

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

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

最佳答案

这是因为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);

关于android - RecyclerView 的对讲功能不好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28923072/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com