是否有可能延长AbsListView做出新的ListView实现?有可能、AbsListView、ListView

2023-09-04 10:45:11 作者:小女子只卖身不卖艺

我一直在寻找创造一个文体不同的列表视图,像许多其他的人,我开始寻找延长AbsListView。每Android的文档,AbsListView是:

I've been looking at creating a stylistically different list view, like many other people, and I started by looking to extend AbsListView. Per the Android doc, AbsListView is:

这可被用来实现物品的虚拟列出的基类。名单没有一个空间的定义在这里。例如,这类的subclases可以在网格中显示的列表的内容,在一个转盘,作为栈等

Base class that can be used to implement virtualized lists of items. A list does not have a spatial definition here. For instance, subclases of this class can display the content of the list in a grid, in a carousel, as stack, etc.

在ListView控件执行一些努力和审查,它看起来像它可能无法延长AbsListView的ListView做,因为这两类连接器和无法访问某些封装件的方式。我偶然在这种形式罗曼盖伊:

After some effort and review of the ListView implementation, it looks like it may not be possible to extend AbsListView the way ListView does because of the coupling of the two classes and the inability to access certain package members. I stumbled on this form Romain Guy:

AbsListView和AbsSpinner被设计内的被扩展   框架。它们也可以扩大在第三方应用程序,但我们做了   不公开所有的目的,必要的保护字段和方法。   我们要非常小心,我们如何揭露此类API,从而不能获得   工具和未来的扩展和内部的变化。我们目前的   建议是,你只需复制/粘贴,你需要里面的code您   应用程序。

AbsListView and AbsSpinner are designed to be extended within the framework. They could also be extended in 3rd party apps but we did not expose all the necessary protected fields and methods on purpose. We want to be very careful in how we expose such APIs so as to not get stuff for future extensions and internal changes. Our current recommendation is you simply copy/paste the code you need inside your app.

我开始尝试这样做,但复制AbsListView成为复制的兔子洞在很多其他的东西,它实际上只是看起来像一个亏本生意。我想看看是否有人已成功延伸AbsListView谁可以共享的方法。

I started trying to do this but copying AbsListView becomes a rabbit hole of copying in a bunch of other stuff and it really just seems like a losing proposition. I wanted to see if anyone has had success extending AbsListView who could share a methodology.

[1] http://developer.android.com/reference/android/widget/AbsListView.html

[2] https://groups.google.com/forum/?fromgroups#!topic/android-developers/UhbR1tpVvF0

推荐答案

还有索尼的一个很好的教程(虽然它们扩展适配器视图,而不是AbsListView)位置:

there is a nice tutorial of sony (though they extend AdapterView and not AbsListView) here:

http://developer.sonymobile.com/2010/05/20/android-tutorial-making-your-own-3d-list-part-1/

http://developer.sonymobile.com/2010/05/31/android-tutorial-making-your-own-3d-list-part-2/

http://developer.sonymobile.com/2010/06/23/android-tutorial-making-your-own-3d-list-part-3/