如何将孩子安排在Recyclerview内

时间:2018-06-15 17:03:00

标签: android firebase firebase-realtime-database android-recyclerview firebaseui

我正在尝试为艺术家建立一个社交网站 当用户单击图像时,图像显示为BlurImageView图像 使用库'com.github.jgabrielfreitas:BlurImageView:1.0.1' 单击图像时,它会很顺利,但是当您单击图片#7时,图像#1将被放置在RecycleView内,并且只会重复前七个图像 我怎样才能克服这个错误?我现在一周都没能解决这个问题 有一个很好的解决方案吗?

这是我的代码:

@Override
protected void onStart() {

mAuth.addAuthStateListener(mAuthListner);
//StoryView();
super.onStart();

FirebaseRecyclerAdapter<panda, PandaViewHolder> FBRA = new FirebaseRecyclerAdapter<panda, PandaViewHolder>(
    panda.class,
    R.layout.home_post_adapter,
    PandaViewHolder.class,
    MData_For_Home

 ) {
@Override
protected void populateViewHolder(final PandaViewHolder viewHolder, final panda model, final int position) {

    final String post_key = getRef(position).getKey();

    viewHolder.setImage(getApplication(), model.getImage());
    viewHolder.isView = true;


    viewHolder.post_image1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {



    if (viewHolder.isView) {
    viewHolder.isView = false;

    viewHolder.post_image1.setBlur(10 / 4);

    viewHolder.post_title.setVisibility(View.VISIBLE);


    } else {
    viewHolder.isView = true;
    //Picasso.with(getApplicationContext()).load(getItem(position).getImage()).into(viewHolder.post_image1);
    //post_image1.setImageResource(Integer.parseInt(image));

    viewHolder.post_image1.setBlur(0);
    viewHolder.post_title.setVisibility(View.INVISIBLE);
    }

    viewHolder.post_title.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
       if (viewHolder.isView) {
       viewHolder.isView = false;
       viewHolder.post_image1.setBlur(10 / 4);
       viewHolder.post_title.setVisibility(View.VISIBLE);
       } else {
       viewHolder.isView = true;

       viewHolder.post_image1.setBlur(0);
       viewHolder.post_title.setVisibility(View.INVISIBLE);
           }
         }
       });
      }
    });

    };
    mPandaList.setAdapter(FBRA);

        }
    public static class PandaViewHolder extends RecyclerView.ViewHolder {

    View mView;

    public PandaViewHolder(View itemView) {


     super(itemView);
     mView = itemView;

     isView = false;

      }


    //post image view
    public void setImage(final Context context, final String image) {
    post_image1 = (BlurImageView) mView.findViewById(R.id.post_imageview);

    Picasso.with(context).load(image).into(post_image1);
    }

0 个答案:

没有答案