我正在尝试在一个视图页内组合图像视图和文本视图。这可能吗?

huangapple go评论73阅读模式
英文:

I am trying to combine a image view and a text view inside of a view pager. Is it possible?

问题

我想在顶部放一张图片,在其下放标题,还要有一个价格标签,这些都需要放在一个ViewPager中。下方的图片展示了我在项目中想要的效果。我正在使用多个数组,其中一个存储图片网址,一个存储标题,另一个存储价格。有没有一种简单的方法来实现这个?
图片描述

英文:

I would like to have an image on top, the title below it, and also a price tag, all within a ViewPager. The image below is what I want in my project. I am using multiple arrays, one which stores the image URL, one which stores the title, and one which stores the price. Is there an easy way of doing this?
enter image description here

答案1

得分: 0

我认为最好的做法是创建一个对象数组(例如命名为StockItem)。然后,您应该为ViewPager创建一个适配器。将StockItem数组设置给这个适配器。此外,您应该为viewpager元素创建一个布局(例如包含图像、标题和价格的垂直线性布局),然后将此视图持有者与StockItem绑定。

英文:

I think that it's better to create an array of objects (name it for example StockItem). Then you should create an adapter for ViewPager. Set array of StockItems to this adapter. Also, you should create a layout for viewpager element (which contains Linear vertical layout for example with image, title and price) and then bind this view holder with StockItem

huangapple
  • 本文由 发表于 2020年9月3日 02:33:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/63711641.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定