从Firebase检索图像不起作用?嗨,我正在上载和从Firebase检索图像。我已经成功完成了上传部分,但是正在进行检索。我遇到了无法从Firebase提取图像的问题。我正在使用Picasso版本:2.5.2
QuoteList.java
public class QuoteList extends AppCompatActivity {
private StorageReference storageRef;
private RecyclerView mRecyclerView;
private DatabaseReference mReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quote_list);
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView = findViewById(R.id.quotes_list);
mRecyclerView.setLayoutManager(layoutManager);
mReference = FirebaseDatabase.getInstance().getReference().child("Quotes");
}
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerAdapter<Quote, QuoteViewHolder> firebaseRecyclerAdapter =
new FirebaseRecyclerAdapter<Quote, QuoteViewHolder>(
Quote.class,
R.layout.quote_row,
QuoteViewHolder.class,
mReference
) {
@Override
protected void populateViewHolder(QuoteViewHolder viewHolder , Quote model , int position) {
viewHolder.setQuotes(model.getQuotes());
viewHolder.setQuoteAuthor(model.getQuote_Author());
viewHolder.setImage(getApplicationContext(),model.getImages());
}
};
mRecyclerView.setAdapter(firebaseRecyclerAdapter);
}
public class QuoteViewHolder extends RecyclerView.ViewHolder{
View mView;
public QuoteViewHolder(View itemView) {
super(itemView);
mView = itemView;
}
public void setQuotes(String Quote){
TextView post_quote = (TextView) mView.findViewById(R.id.post_quote);
post_quote.setText(Quote);
}
public void setQuoteAuthor(String QuoteAuthor){
TextView post_quoteAuthor = (TextView) mView.findViewById(R.id.post_author);
post_quoteAuthor.setText(QuoteAuthor);
}
public void setImage(Context ctx, String image){
ImageView post_image = (ImageView) mView.findViewById(R.id.post_image);
Picasso.with(ctx).load(image).into(post_image);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);
return super.onCreateOptionsMenu(menu);
}
}
作为参考,我使用了YouTube Link。