为什么我在firelerview中显示/不显示我从firebase检索到的图像?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为什么我在firelerview中显示/不显示我从firebase检索到的图像?相关的知识,希望对你有一定的参考价值。
我想将图像上传到firebase存储和firebase实时数据库,并在recyclerview中查看它。图像也包括文本,用户可以在其中指定图像的标题。当试图在recyclerview中显示上传的图像时,只显示文本但图像未显示。下面是我的recyclerview适配器:-firebase realtime database storing the image url and name
`package com.example.fieldhockeybooking;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import java.util.List;
public class RecycleViewAdapter extends RecyclerView.Adapter<RecycleViewAdapter.ViewHolder>
Context context;
List<AdvertUploadInfo> MainImageUploadInfoList;
public RecycleViewAdapter(Context context, List<AdvertUploadInfo> TempList)
this.MainImageUploadInfoList = TempList;
this.context = context;
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_items, parent, false);
ViewHolder viewHolder = new ViewHolder(view);
return viewHolder;
@Override
public void onBindViewHolder(ViewHolder holder, int position)
AdvertUploadInfo UploadInfo = MainImageUploadInfoList.get(position);
holder.imageNameTextView.setText(UploadInfo.getImageName());
//Loading image from Glide library.
Glide.with(context)
.load(UploadInfo.getImageURL())
.into(holder.imageView);
@Override
public int getItemCount()
return MainImageUploadInfoList.size();
class ViewHolder extends RecyclerView.ViewHolder
public ImageView imageView;
public TextView imageNameTextView;
public ViewHolder(View itemView)
super(itemView);
imageView = (ImageView) itemView.findViewById(R.id.imageView);
imageNameTextView = (TextView) itemView.findViewById(R.id.ImageNameTextView);
`
this is what shown from my android apps when i try to show all uploaded images
答案
您必须使用match /allPaths=**
的安全规则来指示所有路径上都允许公共读写访问:
service firebase.storage
match /b/savephoto-a1cc3.appspot.com/o
match /allPaths=**
// Allow access by all users
allow read, write;
另一答案
您必须在firebase实时数据库中设置规则以检索图像并在recyclerview中显示。检查此链接https://firebase.google.com/docs/database/security/
以上是关于为什么我在firelerview中显示/不显示我从firebase检索到的图像?的主要内容,如果未能解决你的问题,请参考以下文章
Android中,我在Activity中用ListView来显示数据,adapter继承BaseAdapter,第一次可显示,重复运行不显示