英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论