Vertical RecyclerView内部的Vertical RecyclerView滚动问题?

时间:2018-09-11 13:01:20

标签: android scroll android-recyclerview

我必须实施带有回复的评论列表。我在评论中使用了相同的项目,这是答复。但是当我有多条评论要回复并向上滚动到它时,“ Recycler View”在绑定该项目时会失去位置。

public void setItem(Adaptable item) {
        super.setItem(item);
        this.comment = (Comment) item;
        binding.setComment(comment);
        binding.setViewHolder(this);
        binding.tvMessage.setText(getFormattedText());
        initReplies();
    }

private void initReplies() {
        if (comment.repliesCount <= 0) {
            binding.recyclerView.setVisibility(View.GONE);
            return;
        }
        binding.recyclerView.setVisibility(View.VISIBLE);
        binding.recyclerView.setNestedScrollingEnabled(false);
        if (adapter == null) {
            LinearLayoutManager layoutManager = new LinearLayoutManager(fragment.getContext(), LinearLayoutManager.VERTICAL, true);              
            binding.recyclerView.setLayoutManager(layoutManager);
            adapter = new RecyclerViewAdapter(fragment, Pages.ID_COMMENTS_REPLY, false);
        }
        adapter.clear();
        adapter.addItems(new ArrayList<>(comment.replies), getCommentMeta());
        binding.recyclerView.setAdapter(adapter);
    }
我从onBindViewHolder调用的

setItem方法

0 个答案:

没有答案