How to populate listview with images and text from Firebase?
up vote
0
down vote
favorite
I am trying to make a listview with images and text, side by side, for every user except the current user (i.e. user of the device).
I have the JSON structure like following:
|
--- users
|
|
--- uid1
| |
| -- uid1
| |
| -- name
| |
| -- imageURL
| |
-- status
|
-- email
|
-- line
|
|
--- uid2
This is my adapter class:
public class MyAdapter extends ArrayAdapter<OtherUsers> {
private Activity context;
private int resource;
private List<OtherUsers> list;
public DayAdapter(@NonNull Activity context, int resource, List<OtherUsers> objects) {
super(context, resource, objects);
this.context = context;
this.resource = resource;
this.list = objects;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
// I am not able to figure out this part
}
}
OtherUsers class
public class OtherUsers {
private String line;
private String imageURL;
public OtherUsers(String line, String imageURL){
this.line = line;
this.imageURL = imageURL;
}
public OtherUsers(){
}
public String getLine(){
return line;
}
public String getImageURL(){
return imageURL;
}
public void setLinee(String line){
this.line = line;
}
public void setImageURL(String imageURL){
this.imageURL = imageURL;
}
}
My list view has XML code like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/back2"
android:layout_width="match_parent"
android:padding="15dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="80dp"
android:id="@+id/image"
android:layout_height="80dp"
android:layout_weight="0.11"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dlne"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/image"
android:layout_toRightOf="@+id/image"
android:textColor="#333"
android:textSize="22sp"
android:textStyle="bold"/>
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/button1"
android:elevation="10dp"
app:fabSize="normal"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="@drawable/profile"
android:layout_alignParentEnd="true" />
</RelativeLayout>
I am not stuck at getting the data. I can retrieve the data from Firebase, I am not able to understand how can I populate the listview with images and lines.
I would appreciate if someone can help me in this.
java android firebase listview firebase-realtime-database
add a comment |
up vote
0
down vote
favorite
I am trying to make a listview with images and text, side by side, for every user except the current user (i.e. user of the device).
I have the JSON structure like following:
|
--- users
|
|
--- uid1
| |
| -- uid1
| |
| -- name
| |
| -- imageURL
| |
-- status
|
-- email
|
-- line
|
|
--- uid2
This is my adapter class:
public class MyAdapter extends ArrayAdapter<OtherUsers> {
private Activity context;
private int resource;
private List<OtherUsers> list;
public DayAdapter(@NonNull Activity context, int resource, List<OtherUsers> objects) {
super(context, resource, objects);
this.context = context;
this.resource = resource;
this.list = objects;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
// I am not able to figure out this part
}
}
OtherUsers class
public class OtherUsers {
private String line;
private String imageURL;
public OtherUsers(String line, String imageURL){
this.line = line;
this.imageURL = imageURL;
}
public OtherUsers(){
}
public String getLine(){
return line;
}
public String getImageURL(){
return imageURL;
}
public void setLinee(String line){
this.line = line;
}
public void setImageURL(String imageURL){
this.imageURL = imageURL;
}
}
My list view has XML code like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/back2"
android:layout_width="match_parent"
android:padding="15dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="80dp"
android:id="@+id/image"
android:layout_height="80dp"
android:layout_weight="0.11"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dlne"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/image"
android:layout_toRightOf="@+id/image"
android:textColor="#333"
android:textSize="22sp"
android:textStyle="bold"/>
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/button1"
android:elevation="10dp"
app:fabSize="normal"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="@drawable/profile"
android:layout_alignParentEnd="true" />
</RelativeLayout>
I am not stuck at getting the data. I can retrieve the data from Firebase, I am not able to understand how can I populate the listview with images and lines.
I would appreciate if someone can help me in this.
java android firebase listview firebase-realtime-database
Something like that stackoverflow.com/questions/6958279/…
– Access Denied
Nov 11 at 7:55
2
Take a look at the following article: androidinterview.com/…
– Access Denied
Nov 11 at 7:57
Check also this out.
– Alex Mamo
Nov 12 at 19:16
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to make a listview with images and text, side by side, for every user except the current user (i.e. user of the device).
I have the JSON structure like following:
|
--- users
|
|
--- uid1
| |
| -- uid1
| |
| -- name
| |
| -- imageURL
| |
-- status
|
-- email
|
-- line
|
|
--- uid2
This is my adapter class:
public class MyAdapter extends ArrayAdapter<OtherUsers> {
private Activity context;
private int resource;
private List<OtherUsers> list;
public DayAdapter(@NonNull Activity context, int resource, List<OtherUsers> objects) {
super(context, resource, objects);
this.context = context;
this.resource = resource;
this.list = objects;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
// I am not able to figure out this part
}
}
OtherUsers class
public class OtherUsers {
private String line;
private String imageURL;
public OtherUsers(String line, String imageURL){
this.line = line;
this.imageURL = imageURL;
}
public OtherUsers(){
}
public String getLine(){
return line;
}
public String getImageURL(){
return imageURL;
}
public void setLinee(String line){
this.line = line;
}
public void setImageURL(String imageURL){
this.imageURL = imageURL;
}
}
My list view has XML code like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/back2"
android:layout_width="match_parent"
android:padding="15dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="80dp"
android:id="@+id/image"
android:layout_height="80dp"
android:layout_weight="0.11"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dlne"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/image"
android:layout_toRightOf="@+id/image"
android:textColor="#333"
android:textSize="22sp"
android:textStyle="bold"/>
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/button1"
android:elevation="10dp"
app:fabSize="normal"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="@drawable/profile"
android:layout_alignParentEnd="true" />
</RelativeLayout>
I am not stuck at getting the data. I can retrieve the data from Firebase, I am not able to understand how can I populate the listview with images and lines.
I would appreciate if someone can help me in this.
java android firebase listview firebase-realtime-database
I am trying to make a listview with images and text, side by side, for every user except the current user (i.e. user of the device).
I have the JSON structure like following:
|
--- users
|
|
--- uid1
| |
| -- uid1
| |
| -- name
| |
| -- imageURL
| |
-- status
|
-- email
|
-- line
|
|
--- uid2
This is my adapter class:
public class MyAdapter extends ArrayAdapter<OtherUsers> {
private Activity context;
private int resource;
private List<OtherUsers> list;
public DayAdapter(@NonNull Activity context, int resource, List<OtherUsers> objects) {
super(context, resource, objects);
this.context = context;
this.resource = resource;
this.list = objects;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
// I am not able to figure out this part
}
}
OtherUsers class
public class OtherUsers {
private String line;
private String imageURL;
public OtherUsers(String line, String imageURL){
this.line = line;
this.imageURL = imageURL;
}
public OtherUsers(){
}
public String getLine(){
return line;
}
public String getImageURL(){
return imageURL;
}
public void setLinee(String line){
this.line = line;
}
public void setImageURL(String imageURL){
this.imageURL = imageURL;
}
}
My list view has XML code like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/back2"
android:layout_width="match_parent"
android:padding="15dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="80dp"
android:id="@+id/image"
android:layout_height="80dp"
android:layout_weight="0.11"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dlne"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/image"
android:layout_toRightOf="@+id/image"
android:textColor="#333"
android:textSize="22sp"
android:textStyle="bold"/>
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/button1"
android:elevation="10dp"
app:fabSize="normal"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="@drawable/profile"
android:layout_alignParentEnd="true" />
</RelativeLayout>
I am not stuck at getting the data. I can retrieve the data from Firebase, I am not able to understand how can I populate the listview with images and lines.
I would appreciate if someone can help me in this.
java android firebase listview firebase-realtime-database
java android firebase listview firebase-realtime-database
asked Nov 11 at 7:20
Manhar
65112
65112
Something like that stackoverflow.com/questions/6958279/…
– Access Denied
Nov 11 at 7:55
2
Take a look at the following article: androidinterview.com/…
– Access Denied
Nov 11 at 7:57
Check also this out.
– Alex Mamo
Nov 12 at 19:16
add a comment |
Something like that stackoverflow.com/questions/6958279/…
– Access Denied
Nov 11 at 7:55
2
Take a look at the following article: androidinterview.com/…
– Access Denied
Nov 11 at 7:57
Check also this out.
– Alex Mamo
Nov 12 at 19:16
Something like that stackoverflow.com/questions/6958279/…
– Access Denied
Nov 11 at 7:55
Something like that stackoverflow.com/questions/6958279/…
– Access Denied
Nov 11 at 7:55
2
2
Take a look at the following article: androidinterview.com/…
– Access Denied
Nov 11 at 7:57
Take a look at the following article: androidinterview.com/…
– Access Denied
Nov 11 at 7:57
Check also this out.
– Alex Mamo
Nov 12 at 19:16
Check also this out.
– Alex Mamo
Nov 12 at 19:16
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f53246647%2fhow-to-populate-listview-with-images-and-text-from-firebase%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
Something like that stackoverflow.com/questions/6958279/…
– Access Denied
Nov 11 at 7:55
2
Take a look at the following article: androidinterview.com/…
– Access Denied
Nov 11 at 7:57
Check also this out.
– Alex Mamo
Nov 12 at 19:16