无法从recyclerview获取子视图

时间:2019-08-26 14:05:52

标签: android android-layout android-recyclerview

我尝试滚动recyclerView的特定位置,然后执行自己的逻辑。这是我的代码

private void showShadow(int pos, String message) {
        if (pos > 0) {
            templateList.getRecyclerView().scrollToPosition(pos);
        }
        holder = templateList.getRecyclerView().findViewHolderForAdapterPosition(pos);
        if (holder == null) {
            new Handler().postDelayed(() -> {
                holder = templateList.getRecyclerView().findViewHolderForAdapterPosition(pos);
                if (holder != null) {
                    SwipeMenuLayout swipeMenuLayout = holder.itemView.findViewById(R.id.SwipeMenuLayout);
                    View directDebitIcon = holder.itemView.findViewById(R.id.direct_debit_icon);
                    if (swipeMenuLayout != null && directDebitIcon != null) {
                        swipeMenuLayout.smoothExpand();
                        new Handler().postDelayed(() -> showCaseView(message, directDebitIcon, getActivity(), swipeMenuLayout), 400);

                    }
                }
            }, 100);


        }

}

我调试了它,但无法从childView中获取视图,我的意思是SwipeMenuLayout和directDebitIcon为空

有人能告诉我在这种情况下怎么了吗? 谢谢

0 个答案:

没有答案