自定义可更新的ListView - Android的发展自定义、ListView、Android

2023-09-06 06:37:58 作者:粉色跳楼少女

至于我的第一个Android应用程序来学习Android SDK的一个目标,我想创建一个特定的URL一个简单的RSS阅读器。无视目标的网络方面,我有得到一个ListView显示自定义布局的麻烦。

As a goal for my first Android application to learn the Android SDK, I am trying to create a simple RSS viewer for a specific url. Disregarding the networking side of the goal, I am having trouble with getting a listView to display a custom layout.

我想要做的是有一个列表视图中的每一行显示两个图像(已读或未读),其次是一些文字之一。我真的不有一个问题,它更是不会有,我能找到(我可能是找错了地方),涵盖取决于code条件自定义布局。任何例子

What I'd like to do is have each row of a list view show one of two images(read or unread), followed by some text. I'm not really having a problem, it's more that there aren't any examples that I could find (I might be looking in the wrong place) that covered custom layouts depending on conditions in code.

任何帮助吗?

推荐答案

下面是一个免费摘录从讨论所涉及的技术,我的书之一。简而言之,你将需要扩展适配器类(例如, ArrayAdapter 的CursorAdapter ),并采取直接控制创建行,这样你就可以应用所需的业务逻辑。

Here is a free excerpt from one of my books that discusses the techniques involved. In a nutshell, you will need to extend your Adapter class (e.g., ArrayAdapter, CursorAdapter) and take direct control over the creation of rows, so you can apply your desired business logic.