简体   繁体   English

在Android ListView中的文本旁边显示来自REST服务的图像

[英]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. 您应该将RecyclerViewViewHolder一起使用,该ViewHolder定义列表中每个项目的显示格式(在您的情况下为具有TextViewImageView的布局),以及RecyclerView.Adapter来管理列表数据。 You could then load the images using a library such as Glide or Picasso . 然后,您可以使用GlidePicasso之类的库加载图像。

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.

相关问题 在列表视图中显示Web服务的结果 - show results of web service rest in a listview android 如何在Android中的简单ListView ListAdapter中显示图像 - How to display images in simple listview listadapter in android 如何从 Kotlin 中的 Android 应用程序发送文本和图像? - How can I tweet texts and images from an Android App in Kotlin? Android Java ListView从Firebase数据库检索列表,但显示空的TextViews和图像 - Android Java ListView retrieve the list from Firebase database but display empty TextViews and Images 没有从服务器获取图像到我在Android中的Listview - not getting Images from server into my Listview in android 从相机捕获图像并将其设置为android中的listview - capturing images from camera and setting into listview in android Android ListView具有来自特殊哈希图的图像 - Android ListView with images from special hashmap 如何从Firebase下载各种类型的文件(图像,视频,文本)并显示它们 - How do I download various types of files(images, videos , texts) from Firebase and display them 如何在Android Studio中将图像与文本链接? - How to link images with texts in android studio? Android-从SQLite获取数据并在ListView中显示 - Android - Fetch data from SQLite and display in ListView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM