简体   繁体   中英

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.

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.

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

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. You could then load the images using a library such as Glide or Picasso .

A good basic tutorial on RecyclerView can be found here https://guides.codepath.com/android/using-the-recyclerview

通过将图像转换为Base64字符串,然后通过JSON将其发送到客户端,我能够做到这一点。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM