【问题标题】:Unable to place ads between Recyclerview using firebase UI for fetching firestore data无法使用 Firebase UI 在 Recyclerview 之间放置广告以获取 Firestore 数据
【发布时间】:2020-05-18 14:05:14
【问题描述】:

我的适配器类

public class ShayariAdapter extends FirestoreRecyclerAdapter<ShayariModel, ShayariAdapter.ShayariViewHolder> {

    private OnItemClickListener listener;
    public interface OnItemClickListener {
        void onItemClick(DocumentSnapshot documentSnapshot, int position);
    }

    public void setOnItemClickListener(OnItemClickListener listener) {
        this.listener = listener;
    }

    public ShayariAdapter(@NonNull FirestoreRecyclerOptions<ShayariModel> options) {
        super(options);
    }

    @Override
    protected void onBindViewHolder(@NonNull ShayariViewHolder holder, int position, @NonNull ShayariModel model) {
        holder.body.setText(model.getBody());
        holder.category.setText(model.getCategory());
        holder.author.setText(model.getAuthor());
    }

    @NonNull
    @Override
    public ShayariViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.shayari_card, parent, false);
        return new ShayariViewHolder(view);
    }


    class ShayariViewHolder extends RecyclerView.ViewHolder {
        TextView body, author;
        TextView category;
        ImageView shareShayari;
        public ShayariViewHolder(@NonNull View itemView) {
            super(itemView);
            body = itemView.findViewById(R.id.shayariText);
            category = itemView.findViewById(R.id.category);
            author = itemView.findViewById(R.id.authorName);
            shareShayari = itemView.findViewById(R.id.shareShayari);

            shareShayari.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int position = getAdapterPosition();
                    if (position != RecyclerView.NO_POSITION && listener != null) {
                        listener.onItemClick(getSnapshots().getSnapshot(position), position);
                    }
                }
            });
        }
    }
}

我无法在 recyclerview 项目之间添加广告,因为有简单适配器的教程,但找不到 FirebaseUI Recyclerview 适配器的教程

我尝试过 google codelab 教程,但卡在 getItemViewType 中。尝试了很多事情并停留在这个

【问题讨论】:

    标签: android firebase android-recyclerview ads firebaseui


    【解决方案1】:

    FirebaseUI 不允许您更改用于呈现视图的数据。这只是开始将 Firestore 中的数据显示到 RecyclerView 的一种非常简单的方法。如果您有更高级的情况需要添加或修改查询结果,则需要构建自己的适配器。

    【讨论】:

    • 所以这对firebaseui来说意味着没有,而是我必须使用我自己的自定义Recyclerview适配器
    • 这就是我要说的,是的。 FirebaseUI 是开源的,因此您可以从中复制。
    • 但是我对Java还不是很精通,你能帮帮我吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-28
    • 2018-02-05
    • 1970-01-01
    • 1970-01-01
    • 2021-12-22
    相关资源
    最近更新 更多