【问题标题】:Android - How do you bind a ListView to a collection of custom objects?Android - 如何将 ListView 绑定到自定义对象的集合?
【发布时间】:2010-02-23 13:13:14
【问题描述】:

我有一个名为 PhoneContact 的类,它有 3 个属性: 标题描述电话号码

如果我有这些集合,我将如何将它们绑定到包含每个属性的 TextViewListView

【问题讨论】:

    标签: android data-binding listview


    【解决方案1】:

    扩展ArrayAdapter,覆盖getView(int, View, ViewGroup)

    为了连接您的自定义适配器,我假设您的 Activity 扩展了 ListActivity。在其中一种生命周期方法(例如onCreate()onResume()onStart())中,调用setListAdapter(myCustomAdapter)

    本文展示了如何做到这一点:Android 系列:Custom ListView items and adapters

    【讨论】:

    • 当你回答时我刚刚浏览了那个页面,正是我想要的。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2022-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-17
    • 2011-07-27
    • 2012-12-31
    相关资源
    最近更新 更多