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.










share|improve this question





















  • 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














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.










share|improve this question





















  • 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












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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 7:20









Manhar

60112




60112











  • 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






  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto