How to populate listview with images from Firebase Database in android?
up vote
1
down vote
favorite
I have stored links to the images in my Firebase storage to my Firebase Database. The JSON structure for my database is something like this:
|
--- users
|
|
---- uid1
| |
| -- uid1
| |
| -- name
| |
| -- imageURL
| |
|
|
-- uid2
What I want to do is populate my listview with images from this. I also need to know how to populate listview with images.
I read some answers on stack overflow but I couldn't understand how should I start with this.
I would appreciate if someone could provide information and some code to start with this.
EDIT:
I am able to get the imageURL from the database, I was not stuck in that. I want to know how can I populate listview with images? I saw some answers on StackOverflow but none of them could properly address my problem.
java
add a comment |
up vote
1
down vote
favorite
I have stored links to the images in my Firebase storage to my Firebase Database. The JSON structure for my database is something like this:
|
--- users
|
|
---- uid1
| |
| -- uid1
| |
| -- name
| |
| -- imageURL
| |
|
|
-- uid2
What I want to do is populate my listview with images from this. I also need to know how to populate listview with images.
I read some answers on stack overflow but I couldn't understand how should I start with this.
I would appreciate if someone could provide information and some code to start with this.
EDIT:
I am able to get the imageURL from the database, I was not stuck in that. I want to know how can I populate listview with images? I saw some answers on StackOverflow but none of them could properly address my problem.
java
If you are using recyclerview, you can fetch the list of data from firebase and get the image in Adapter using picasso.
– ManishPrajapati
Nov 10 at 14:53
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have stored links to the images in my Firebase storage to my Firebase Database. The JSON structure for my database is something like this:
|
--- users
|
|
---- uid1
| |
| -- uid1
| |
| -- name
| |
| -- imageURL
| |
|
|
-- uid2
What I want to do is populate my listview with images from this. I also need to know how to populate listview with images.
I read some answers on stack overflow but I couldn't understand how should I start with this.
I would appreciate if someone could provide information and some code to start with this.
EDIT:
I am able to get the imageURL from the database, I was not stuck in that. I want to know how can I populate listview with images? I saw some answers on StackOverflow but none of them could properly address my problem.
java
I have stored links to the images in my Firebase storage to my Firebase Database. The JSON structure for my database is something like this:
|
--- users
|
|
---- uid1
| |
| -- uid1
| |
| -- name
| |
| -- imageURL
| |
|
|
-- uid2
What I want to do is populate my listview with images from this. I also need to know how to populate listview with images.
I read some answers on stack overflow but I couldn't understand how should I start with this.
I would appreciate if someone could provide information and some code to start with this.
EDIT:
I am able to get the imageURL from the database, I was not stuck in that. I want to know how can I populate listview with images? I saw some answers on StackOverflow but none of them could properly address my problem.
java
java
edited Nov 11 at 5:17
asked Nov 10 at 14:30
Manhar
56112
56112
If you are using recyclerview, you can fetch the list of data from firebase and get the image in Adapter using picasso.
– ManishPrajapati
Nov 10 at 14:53
add a comment |
If you are using recyclerview, you can fetch the list of data from firebase and get the image in Adapter using picasso.
– ManishPrajapati
Nov 10 at 14:53
If you are using recyclerview, you can fetch the list of data from firebase and get the image in Adapter using picasso.
– ManishPrajapati
Nov 10 at 14:53
If you are using recyclerview, you can fetch the list of data from firebase and get the image in Adapter using picasso.
– ManishPrajapati
Nov 10 at 14:53
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
This can be done by fetching the image url from Firebase in your adapter or wherever you want to set your image. A sample code assuming you have a list of images to use:
FirebaseDatabase.getInstance().getReference().child("users").addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
for(DataSnapshot ds:dataSnapshot.getChildren())
String image = ds.child("image").getValue(String.class);
// You can now set your Image with any method you want, Glide Picasso or any other library
// GlideApp.with(getContext())
// .load(image)
// .placeholder(new ColorDrawable(getResources().getColor(R.color.colorWhite)))// you can use any color here
// .fitCenter()
// .into(image_view);// An ImageView instance
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
);
What is being done here, should be where you fetch your items to be displayed in the ListView. After obtaining the list, you can then pass them into your adapter. The commented GlideApp call is supposed to happen in the getView method of your adapter
Thank you for your answer, can you tell how can I populate listview with images from this? Do I have to put imageviews inside the listview, but there are dynamic number of users and hence I can't just put a fixed number of image views
– Manhar
Nov 10 at 15:31
Can you post more details about how you are already implementing your list view updates?
– Cool Guy CG
Nov 10 at 15:55
Can you tell how can I do that. I edited the question. I would provide the code, but I am not getting how can I implement this. I have just a listview and I am trying to find out the way to populate it with images.
– Manhar
Nov 11 at 5:21
add a comment |
up vote
0
down vote
If you can use the retrofit to fetch the images from Firebase, then it would be very easy to populate the images into RecyclerView. If you are not aware of the retrofit, you can follow this great tutorial. https://www.raywenderlich.com/4539-android-networking
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
This can be done by fetching the image url from Firebase in your adapter or wherever you want to set your image. A sample code assuming you have a list of images to use:
FirebaseDatabase.getInstance().getReference().child("users").addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
for(DataSnapshot ds:dataSnapshot.getChildren())
String image = ds.child("image").getValue(String.class);
// You can now set your Image with any method you want, Glide Picasso or any other library
// GlideApp.with(getContext())
// .load(image)
// .placeholder(new ColorDrawable(getResources().getColor(R.color.colorWhite)))// you can use any color here
// .fitCenter()
// .into(image_view);// An ImageView instance
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
);
What is being done here, should be where you fetch your items to be displayed in the ListView. After obtaining the list, you can then pass them into your adapter. The commented GlideApp call is supposed to happen in the getView method of your adapter
Thank you for your answer, can you tell how can I populate listview with images from this? Do I have to put imageviews inside the listview, but there are dynamic number of users and hence I can't just put a fixed number of image views
– Manhar
Nov 10 at 15:31
Can you post more details about how you are already implementing your list view updates?
– Cool Guy CG
Nov 10 at 15:55
Can you tell how can I do that. I edited the question. I would provide the code, but I am not getting how can I implement this. I have just a listview and I am trying to find out the way to populate it with images.
– Manhar
Nov 11 at 5:21
add a comment |
up vote
1
down vote
This can be done by fetching the image url from Firebase in your adapter or wherever you want to set your image. A sample code assuming you have a list of images to use:
FirebaseDatabase.getInstance().getReference().child("users").addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
for(DataSnapshot ds:dataSnapshot.getChildren())
String image = ds.child("image").getValue(String.class);
// You can now set your Image with any method you want, Glide Picasso or any other library
// GlideApp.with(getContext())
// .load(image)
// .placeholder(new ColorDrawable(getResources().getColor(R.color.colorWhite)))// you can use any color here
// .fitCenter()
// .into(image_view);// An ImageView instance
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
);
What is being done here, should be where you fetch your items to be displayed in the ListView. After obtaining the list, you can then pass them into your adapter. The commented GlideApp call is supposed to happen in the getView method of your adapter
Thank you for your answer, can you tell how can I populate listview with images from this? Do I have to put imageviews inside the listview, but there are dynamic number of users and hence I can't just put a fixed number of image views
– Manhar
Nov 10 at 15:31
Can you post more details about how you are already implementing your list view updates?
– Cool Guy CG
Nov 10 at 15:55
Can you tell how can I do that. I edited the question. I would provide the code, but I am not getting how can I implement this. I have just a listview and I am trying to find out the way to populate it with images.
– Manhar
Nov 11 at 5:21
add a comment |
up vote
1
down vote
up vote
1
down vote
This can be done by fetching the image url from Firebase in your adapter or wherever you want to set your image. A sample code assuming you have a list of images to use:
FirebaseDatabase.getInstance().getReference().child("users").addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
for(DataSnapshot ds:dataSnapshot.getChildren())
String image = ds.child("image").getValue(String.class);
// You can now set your Image with any method you want, Glide Picasso or any other library
// GlideApp.with(getContext())
// .load(image)
// .placeholder(new ColorDrawable(getResources().getColor(R.color.colorWhite)))// you can use any color here
// .fitCenter()
// .into(image_view);// An ImageView instance
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
);
What is being done here, should be where you fetch your items to be displayed in the ListView. After obtaining the list, you can then pass them into your adapter. The commented GlideApp call is supposed to happen in the getView method of your adapter
This can be done by fetching the image url from Firebase in your adapter or wherever you want to set your image. A sample code assuming you have a list of images to use:
FirebaseDatabase.getInstance().getReference().child("users").addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
for(DataSnapshot ds:dataSnapshot.getChildren())
String image = ds.child("image").getValue(String.class);
// You can now set your Image with any method you want, Glide Picasso or any other library
// GlideApp.with(getContext())
// .load(image)
// .placeholder(new ColorDrawable(getResources().getColor(R.color.colorWhite)))// you can use any color here
// .fitCenter()
// .into(image_view);// An ImageView instance
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
);
What is being done here, should be where you fetch your items to be displayed in the ListView. After obtaining the list, you can then pass them into your adapter. The commented GlideApp call is supposed to happen in the getView method of your adapter
edited Nov 10 at 15:54
answered Nov 10 at 15:15
Cool Guy CG
69548
69548
Thank you for your answer, can you tell how can I populate listview with images from this? Do I have to put imageviews inside the listview, but there are dynamic number of users and hence I can't just put a fixed number of image views
– Manhar
Nov 10 at 15:31
Can you post more details about how you are already implementing your list view updates?
– Cool Guy CG
Nov 10 at 15:55
Can you tell how can I do that. I edited the question. I would provide the code, but I am not getting how can I implement this. I have just a listview and I am trying to find out the way to populate it with images.
– Manhar
Nov 11 at 5:21
add a comment |
Thank you for your answer, can you tell how can I populate listview with images from this? Do I have to put imageviews inside the listview, but there are dynamic number of users and hence I can't just put a fixed number of image views
– Manhar
Nov 10 at 15:31
Can you post more details about how you are already implementing your list view updates?
– Cool Guy CG
Nov 10 at 15:55
Can you tell how can I do that. I edited the question. I would provide the code, but I am not getting how can I implement this. I have just a listview and I am trying to find out the way to populate it with images.
– Manhar
Nov 11 at 5:21
Thank you for your answer, can you tell how can I populate listview with images from this? Do I have to put imageviews inside the listview, but there are dynamic number of users and hence I can't just put a fixed number of image views
– Manhar
Nov 10 at 15:31
Thank you for your answer, can you tell how can I populate listview with images from this? Do I have to put imageviews inside the listview, but there are dynamic number of users and hence I can't just put a fixed number of image views
– Manhar
Nov 10 at 15:31
Can you post more details about how you are already implementing your list view updates?
– Cool Guy CG
Nov 10 at 15:55
Can you post more details about how you are already implementing your list view updates?
– Cool Guy CG
Nov 10 at 15:55
Can you tell how can I do that. I edited the question. I would provide the code, but I am not getting how can I implement this. I have just a listview and I am trying to find out the way to populate it with images.
– Manhar
Nov 11 at 5:21
Can you tell how can I do that. I edited the question. I would provide the code, but I am not getting how can I implement this. I have just a listview and I am trying to find out the way to populate it with images.
– Manhar
Nov 11 at 5:21
add a comment |
up vote
0
down vote
If you can use the retrofit to fetch the images from Firebase, then it would be very easy to populate the images into RecyclerView. If you are not aware of the retrofit, you can follow this great tutorial. https://www.raywenderlich.com/4539-android-networking
add a comment |
up vote
0
down vote
If you can use the retrofit to fetch the images from Firebase, then it would be very easy to populate the images into RecyclerView. If you are not aware of the retrofit, you can follow this great tutorial. https://www.raywenderlich.com/4539-android-networking
add a comment |
up vote
0
down vote
up vote
0
down vote
If you can use the retrofit to fetch the images from Firebase, then it would be very easy to populate the images into RecyclerView. If you are not aware of the retrofit, you can follow this great tutorial. https://www.raywenderlich.com/4539-android-networking
If you can use the retrofit to fetch the images from Firebase, then it would be very easy to populate the images into RecyclerView. If you are not aware of the retrofit, you can follow this great tutorial. https://www.raywenderlich.com/4539-android-networking
answered Nov 10 at 16:19
hemandroid
317
317
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239941%2fhow-to-populate-listview-with-images-from-firebase-database-in-android%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you are using recyclerview, you can fetch the list of data from firebase and get the image in Adapter using picasso.
– ManishPrajapati
Nov 10 at 14:53