Android 迭代反馈与 RecycleView 的隐藏的项目

标签: Android
发布时间: 2017/1/23 4:33:56
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

Recycleview 具有超过 10 项里面了因为它有十多项,它显示在一个只有 4 项 time 。我想要在列表中拖动左/右的行动,但后 4 循环问题带有反馈。项目焦点转上另一个 view 上的组件 layout 。我如何可以循环访问 recycleview 与反馈的所有项目?

编辑︰ 我用我自己这样的辅助功能委托︰

mRecyclerView.setAccessibilityDelegate(mAccessibilityDelegate);


public class AccessibilityDelegate extends View.AccessibilityDelegate {

private Assistant mAssistant;

public AccessibilityDelegate(Assistant assistant)
{
    mAssistant = assistant;
}

@Override
public void sendAccessibilityEvent(View host, int eventType) {
    if(!mAssistant.isSpeaking() && mAssistant.isRecognizerAvailable())
    {
        super.sendAccessibilityEvent(host, eventType);
    }
}

@Override
public boolean performAccessibilityAction(View host, int action, Bundle args) {
    if(!mAssistant.isSpeaking() && mAssistant.isRecognizerAvailable())
    {
        return super.performAccessibilityAction(host, action, args);
    }

    return false;
}

@Override
public void sendAccessibilityEventUnchecked(View host, AccessibilityEvent event) {
    super.sendAccessibilityEventUnchecked(host, event);
}

@Override
public boolean dispatchPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
    return super.dispatchPopulateAccessibilityEvent(host, event);
}

@Override
public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onPopulateAccessibilityEvent(host, event);
}

@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
}

@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
}

@Override
public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, AccessibilityEvent event) {
    return super.onRequestSendAccessibilityEvent(host, child, event);
}

@Override
public AccessibilityNodeProvider getAccessibilityNodeProvider(View host) {
    return super.getAccessibilityNodeProvider(host);
}

}

解决方法 1:

之后的几个试验,我发现了这个问题。

重写 RecycleView 的可访问性功能扩展了 RecyclerViewAccessibilityDelegate。

    //mRecyclerView.setAccessibilityDelegate(mAccessibilityDelegate);
    RVAccessibilityDelegate rvAccessibilityDelegate = new RVAccessibilityDelegate(mRecyclerView, mAssistant);
    mRecyclerView.setAccessibilityDelegateCompat(rvAccessibilityDelegate);

此外,如果您想要禁用宣布像"6 第 1 项显示"只需注释出 super.sendAccessibilityEventUnchecked (主机、 事件)

public class RVAccessibilityDelegate extends RecyclerViewAccessibilityDelegate {

private Assistant mAssistant;

public RVAccessibilityDelegate(RecyclerView recyclerView, Assistant assistant) {
    super(recyclerView);
    mAssistant = assistant;
}

@Override
public boolean performAccessibilityAction(View host, int action, Bundle args) {
    if(!mAssistant.isSpeaking() && mAssistant.isRecognizerAvailable())
    {
        return super.performAccessibilityAction(host, action, args);
    }

    return false;
}

@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
}

@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
}

@Override
public void sendAccessibilityEvent(View host, int eventType) {
    if(!mAssistant.isSpeaking() && mAssistant.isRecognizerAvailable())
    {
        super.sendAccessibilityEvent(host, eventType);
    }
}

@Override
public void sendAccessibilityEventUnchecked(View host, AccessibilityEvent event) {
    //super.sendAccessibilityEventUnchecked(host, event);
}

@Override
public boolean dispatchPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
    return super.dispatchPopulateAccessibilityEvent(host, event);
}

@Override
public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onPopulateAccessibilityEvent(host, event);
}

@Override
public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, AccessibilityEvent event) {
    return super.onRequestSendAccessibilityEvent(host, child, event);
}

@Override
public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View host) {
    return super.getAccessibilityNodeProvider(host);
}

}

官方微信
官方QQ群
31647020