gpt4 book ai didi

java - 我的帖子图片不会显示在主要 Activity 中

转载 作者:行者123 更新时间:2023-12-01 18:01:06 25 4
gpt4 key购买 nike

我已将我的应用程序连接到 Firebase,每当我发布图像时,它都会很好地存储在 Firebase 存储中。但是当我尝试检索我发布的图像时,它并没有这样做,而是只显示我的占位符。没有错误

可能是什么问题?

private void DisplayAllUsersPosts()
{
FirebaseRecyclerOptions<Posts> options =
new FirebaseRecyclerOptions.Builder<Posts>()
.setQuery(PostsRef, Posts.class)
.build();

FirebaseRecyclerAdapter adapter = new FirebaseRecyclerAdapter<Posts, PostsViewHolder>(options) {
@Override
public PostsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.all_posts_layout, parent, false);

return new PostsViewHolder(view);
}

@Override
protected void onBindViewHolder(PostsViewHolder viewHolder, int position, Posts model) {

//get position of the post on the grid then gets key
final String PostKey = getRef(position).getKey();

viewHolder.setFullname(model.getFullname());
viewHolder.setTime(model.getTime());
viewHolder.setDate(model.getDate());
viewHolder.setDescription(model.getDescription());
viewHolder.setProfileimage( model.getProfileimage());
viewHolder.setPostimage(model.getPostimage());

//ep27
viewHolder.mView.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent clickPostIntent = new Intent(MainActivity.this,ClickPostActivity.class);
clickPostIntent.putExtra("PostKey", PostKey);
startActivity(clickPostIntent);
}
});

}
};
adapter.startListening();
postList.setAdapter(adapter);
}

最佳答案

 public static class PostsViewHolder extends RecyclerView.ViewHolder
{
View mView;

public PostsViewHolder(View itemView)
{
super(itemView);
mView = itemView;
}

public void setFullname(String fullname)
{
TextView username = (TextView) mView.findViewById(R.id.post_user_name);
username.setText(fullname);
}

public void setProfileimage(String profileimage)
{
CircleImageView image = (CircleImageView) mView.findViewById(R.id.post_profile_image);
Picasso.get().load(profileimage).placeholder(R.drawable.profile).into(image);
}

public void setTime(String time)
{
TextView PostTime = (TextView) mView.findViewById(R.id.post_time);
PostTime.setText(" " + time);
}

public void setDate(String date)
{
TextView PostDate = (TextView) mView.findViewById(R.id.post_date);
PostDate.setText(" " + date);
}

public void setDescription(String description)
{
TextView PostDescription = (TextView) mView.findViewById(R.id.post_description);
PostDescription.setText(description);
}

public void setPostimage( String postimage)
{

ImageView PostImage = (ImageView) mView.findViewById(R.id.post_image);
Picasso.get().load(postimage).placeholder(R.drawable.placeholderr).into(PostImage);


}
}

关于java - 我的帖子图片不会显示在主要 Activity 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60626299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com