Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 回收视图未显示-Xamarin.Droid_C#_Android_Xamarin_Xamarin.android - Fatal编程技术网

C# 回收视图未显示-Xamarin.Droid

C# 回收视图未显示-Xamarin.Droid,c#,android,xamarin,xamarin.android,C#,Android,Xamarin,Xamarin.android,对我来说,我的代码似乎没有什么问题,但我的recyclerView没有出现。如果适配器设置良好,请查看我的代码。非常感谢。请问我的适配器缺少什么?虽然我看到适配器中的datasnapShot正在运行,但我的recyclerView没有显示,但页面显示为空 适配器 public class PhotoHolder : RecyclerView.ViewHolder { public ImageView ImgPhotos; pu

对我来说,我的代码似乎没有什么问题,但我的recyclerView没有出现。如果适配器设置良好,请查看我的代码。非常感谢。请问我的适配器缺少什么?虽然我看到适配器中的datasnapShot正在运行,但我的recyclerView没有显示,但页面显示为空

适配器

 public class PhotoHolder : RecyclerView.ViewHolder
        {


           public ImageView ImgPhotos;

            public PhotoHolder(View itemView):base(itemView)
            {
                ImgPhotos = (ImageView)itemView.FindViewById(Resource.Id.imageView);

            }

            public class PhotoAdapter : RecyclerView.Adapter, IValueEventListener
            {

                public PhotoAdapter(List<Photos> Photos, Context mContext)
                {
                    this.Photos = Photos;
                    this.mContext = mContext;
                    photos = (PhotosActivity)mContext;

                    mDatabaseImage = FirebaseDatabase.Instance.Reference.Child("Photos");

                    mDatabaseImage.AddValueEventListener(this);
                }



                public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
                {
                    hold = holder as PhotoHolder;
                    hold.ImgPhotos.SetImageResource(Resource.Drawable.cheese_5);
                }



                public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
                {
                    View v = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.list_photos, parent, false);
                    PhotoHolder holder = new PhotoHolder(v);

                    return holder;
                }


                public override int ItemCount
                {

                    get { return Photos.Count; }

                }

                public void OnCancelled(DatabaseError error)
                {
                    throw new NotImplementedException();
                }

               public void OnDataChange(DataSnapshot snapshot)
                {
                    var items = snapshot.Children?.ToEnumerable<DataSnapshot>();


                    foreach (DataSnapshot item in items)
                    {

                        map = (HashMap)item.Value;
                        imageUrl = new FilePhotos(map.Get("URL").ToString());
                    }

                }


            }

        }
public-class-PhotoHolder:RecyclerView.ViewHolder
{
公共图像查看ImgPhotos;
公共照片架(视图项目视图):底座(项目视图)
{
ImgPhotos=(ImageView)itemviewbyd(Resource.Id.ImageView);
}
公共类PhotoAdapter:RecyclerView.Adapter,IValueEventListener
{
公共PhotoAdapter(列出照片、上下文mContext)
{
这个。照片=照片;
this.mContext=mContext;
照片=(PhotosActivity)mContext;
mDatabaseImage=FirebaseDatabase.Instance.Reference.Child(“照片”);
mDatabaseImage.AddValueEventListener(此);
}
公共覆盖无效OnBindViewHolder(RecyclerView.ViewHolder,int位置)
{
hold=作为照片支架的支架;
hold.ImgPhotos.SetImageResource(Resource.Drawable.cheese_5);
}
public override RecyclerView.ViewHolder OnCreateViewHolder(视图组父级,int-viewType)
{
视图v=LayoutInflater.From(parent.Context)。充气(Resource.Layout.list\u照片,parent,false);
照片夹=新照片夹(v);
报税表持有人;
}
公共覆盖int ItemCount
{
获取{return Photos.Count;}
}
已取消的公共无效(DatabaseError错误)
{
抛出新的NotImplementedException();
}
公共无效OnDataChange(数据快照快照)
{
var items=snapshot.Children?.ToEnumerable();
foreach(项目中的DataSnapshot项目)
{
map=(HashMap)item.Value;
imageUrl=新文件照片(map.Get(“URL”).ToString());
}
}
}
}
光活性

protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            FrameLayout content = (FrameLayout)FindViewById(Resource.Id.content_frame);
            LayoutInflater.Inflate(Resource.Layout.PhotoView, content);

            adapter = new PhotoAdapter(Photos, this);

            rv = FindViewById<RecyclerView>(Resource.Id.recyclerView);
            rv.SetLayoutManager(new LinearLayoutManager(this));
            rv.SetItemAnimator(new DefaultItemAnimator());
            rv.SetAdapter(adapter);
            adapter.NotifyDataSetChanged();

        }
protectedoverride void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
FrameLayout content=(FrameLayout)findviewbyd(Resource.Id.content\u frame);
LayoutInflater.充气(Resource.Layout.PhotoView,content);
适配器=新的PhotoAdapter(照片,本);
rv=findviewbyd(Resource.Id.recyclerView);
rv.SetLayoutManager(新直线布局经理(本));
rv.SetItemAnimator(新的DefaultItemAnimator());
rv.设置适配器(适配器);
adapter.NotifyDataSetChanged();
}

您的代码看起来正常,请检查布局文件并查看您的recyclerview高度和宽度。另外,请尝试删除动画制作人并检查更改。我看到您的最新案例在recyclerview中询问有关搜索的问题,那么您解决了这个问题吗?@GraceFeng MSFT,是的,我已经解决了,但我的搜索没有按预期进行