[英]Display Images from REST service beside texts in Android ListView
I would like to display images from a Java REST service along side a name on an android ListView. 我想显示Java REST服务中的图像以及android ListView上的名称。
Assuming we have a list of Student Names and their passports in png formats on a REST server, I'll like to create a list on an Android app shows the passport of each student beside their names. 假设我们在REST服务器上有png格式的学生姓名和护照列表,我想在Android应用程序上创建一个列表,在每个学生姓名旁边显示每个学生的护照。
I'm able to display their names but I don't know how to go about returning their passports alongside their name on the REST service as well as displaying the passport on the ListView 我能够显示他们的姓名,但是我不知道如何在REST服务上连同他们的姓名一起退还他们的护照,以及在ListView上显示护照
You should use a RecyclerView
with a ViewHolder
which defines the display format for each item in the list (in your case a layout with a TextView
and an ImageView
) and a RecyclerView.Adapter
to manage the list data. 您应该将
RecyclerView
与ViewHolder
一起使用,该ViewHolder
定义列表中每个项目的显示格式(在您的情况下为具有TextView
和ImageView
的布局),以及RecyclerView.Adapter
来管理列表数据。 You could then load the images using a library such as Glide or Picasso . 然后,您可以使用Glide或Picasso之类的库加载图像。
A good basic tutorial on RecyclerView
can be found here https://guides.codepath.com/android/using-the-recyclerview 可以在以下网址找到有关
RecyclerView
良好基础教程:https: RecyclerView
通过将图像转换为Base64字符串,然后通过JSON将其发送到客户端,我能够做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.