简体   繁体   English

Android上ListActivity中的自定义项目

[英]Custom Item in ListActivity on Android

I've spent hours reading through the SDK reference, googling and reading tutorials - but I still can't figure it out. 我已经花了数小时阅读SDK参考,谷歌搜索和阅读教程-但我仍然无法弄清楚。

I would like to know how to create a custom list item in the ListActivity widget on Android. 我想知道如何在Android的ListActivity小部件中创建自定义列表项。 Something similar to a Twitter client interface. 类似于Twitter客户端界面。 Each list item has different types of text, possibly an icon, etc. 每个列表项都有不同类型的文本,可能还有图标等。

The issue is binding the data to the list item. 问题是将数据绑定到列表项。 If you define your own data structure, let's say "Tweet" which will store the message, author, date sent and a picture URL - how do you bind the tweet instance to the custom list item? 如果您定义自己的数据结构,那么说“ Tweet”,它将存储消息,作者,发送日期和图片URL-您如何将tweet实例绑定到自定义列表项?

Does anyone know of any resources that would help me understand the process of creating something like that? 有人知道有什么资源可以帮助我理解创建类似内容的过程吗?

Any guidance would be appreciated. 任何指导将不胜感激。 Thanks 谢谢

I'm not sure which tutorials you were reading but it's quite simple. 我不确定您正在阅读哪些教程,但这很简单。 You define your layout. 您定义布局。 You use it in your getView for your items. 您可以在getView中将其用于商品。 http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html

you can also look at Mark's example with lazy loading images http://github.com/commonsguy/cwac-thumbnail 您还可以通过延迟加载图像来查看Mark的示例http://github.com/commonsguy/cwac-thumbnail

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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