自定义列表视图?
I have a code made by Fedor, it can be found "here".
The first image is what I have now,
and the second image is what I want to accomplish.
Can someone guide me with this. I have been struggling for days trying to solve this problem.
Please help me, Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个类似的例子。您必须为您的 ListView 创建一个自定义适配器。
http://www.softwarepassion.com/android-series- custom-listview-items-and-adapters/
您可能可以使用该示例的大部分内容。只需更改 row.xml 即可创建所需的布局以及适配器中的 getView() 。
Here is an example of something similar. You have to create a custom adapter for your ListView.
http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/
You can probably use most of that example. Just change the row.xml to create tha layout you want and the getView() in the adapter.
您只需修改列表项布局(在 item.xml 中)即可拥有另一个 ImageView。
并修改 LazyAdapter 的 getView() 方法以添加对第二个 ImageView 的支持。
You just need to modify the list item layout (in item.xml) to have another ImageView.
and modify LazyAdapter's getView() method to add support for the second ImageView.
可以在此处找到创建自定义 ListView 的教程:
http://justcallmebrian.com/?p=139
只需更改每个项目的 XML 布局像 Robby 说的那样有 2 个 ImageView。然后在适配器的 getView 中(如果您遵循其他人的答案,则为 LazyAdapter),您应该有如下内容:
我之前粘贴的教程描述了一种动态生成列表的方法(即没有 R.drawable.icon1/2 的资源并且没有文本图像的文本)。像这样的东西可能会起作用(假设您有一个 Model 类,它将保存所有 3 条信息):
当然,上面的代码片段假设您有一个名为 myList 的 ArrayList,它也可以获取图像名称和要显示的文本。
A tutorial for creating a Custom ListView can be found here:
http://justcallmebrian.com/?p=139
Just need to change the XML layout for each item to have 2 ImageViews like Robby said. Then in your getView of your Adapter (LazyAdapter if you followed along with the other people's answers) you should have something like this:
The tutorial I pasted earlier depicts a way to make the generation of the list dynamic (i.e. not having the resource of R.drawable.icon1/2 and not having the text for your Text images). Something like this may work (assuming you have a Model class that will hold all 3 pieces of information):
Of course the snippet above assumes you have an ArrayList called myList that also getters to get the image names and the text to display.