安卓:垂直画廊? [英] Android: a vertical gallery?

查看:131
本文介绍了安卓:垂直画廊?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个小部件,其行为类似于库组件,但是垂直滚动,而不是水平。我用Google搜索周围,显然答案是否定的,例如pre制部件存在。

所以,我说我自己,哦,我会看在Android源画廊类和修改,而不是垂直滚动。没那么容易。 Android SDK中隐藏了一个手离开(可以理解为框架的维护),但它也使得它很难扩展部件。画廊类,例如,使用大量的成员变量来自其母公司,AbsSpinner(mSelectedPosition,etc.etc),其母公司的母公司,等等......这是不是在所有的应用程序开发者的角度来看访问。如果无法访问这些成员变量,我不能使用从画廊类类似code为我所用。

动起来的继承链,并把这些父类的源$ C ​​$ C都在我的项目,或者从头开始编写小部件的所有不使用现有框架部件已经解决了这个问题,对

总之我不能找到一种方式来获得一个垂直滚动画廊。

时的周围有一个更好的办法吗?为什么Android框架使部件延伸这么难?

解决方案
  

有没有更好的办法在吗?

由于我们不知道你正在构建什么,这很难说。我同意号Yoni Samlan的评论,一个的ListView 可能足以满足您的需求。

  

为什么Android框架化妆   扩展插件这么难?

虽然可以想象,一个重新实现图库可能使您可以更方便,使其取向不同,核心的Andr​​oid团队必须权衡这样重新实现与其他发展重点。

其中的一个重点是SDK的保真度。他们希望确保在可能的最大程度,code为Android 1.5可以写在Android 2.1上运行而无需修改。这在两个方面限制了它们。首先,他们不能随便改变现有的图库,例如,以满足你的愿望,如果这样做会导致他们突破现有的API。二,核Android团队将不会公开新的方法或类,即使这些可能是第三方开发者有益,除非及直至该团队已准备好支持这些方法或类的长途。

Android的最初编写的SDK出现之前。这给出为什么大多数内置的应用(例如,计算器)不能与SDK单独建造的原因,但需要建立作为固件图像的一部分。同样,核Android团队不得不做出的决定,因为创建初始SDK如何最好地利用现有code和创造公共的东西,我们可以一起工作的一部分,并保护/私人的东西,我们不能,用SDK保真心里。正如你可能已经注意到,Android是巨大的,因此创建了SDK必须采取员工时间相应大量。重写它的地段,以增加胜算有人可​​以,比方说,创建一个垂直图库不高可能他们的名单上。

在一个理想的世界,是的,我们将能够更容易地扩展内置部件和显著改变他们的行为。同样,在一个理想的世界,我会发...: - )

I'm looking for a widget that behaves similar to the gallery widget but scrolls vertically instead of horizontally. I googled all around and apparently the answer is no such pre-made widget exists.

So I said myself, oh well, I'll look at the gallery class in the android source and modify that to scroll vertically instead. Not so easy. The android SDK hides a lots away (understandably for framework maintenance), but it also makes it very hard to extend the widgets. The gallery class, for example, use a lots of member variable from its parent, AbsSpinner (mSelectedPosition, etc.etc.), and its parent's parent, etc... which are not at all accessible from the app-developer's standpoint. Without access to those member variable, I cannot use similar code from gallery class for my own use.

Short of moving up the inheritance chain and put the source code of those parent classes all in my project, or writing the widget all from scratch without using the existing framework widgets that already solved the problem, I can't find a way to get a vertical scrolling gallery.

Is there a better way around? Why does the android framework make extending widget so difficult?

解决方案

Is there a better way around?

Since we don't know what you are building, that's impossible to say. I agree with Yoni Samlan's comment that a ListView may be sufficient for your needs.

Why does the android framework make extending widget so difficult?

While it is conceivable that a reimplemented Gallery might make it simpler for you to make it orient differently, the core Android team has to weigh such reimplementation against other development priorities.

One of those priorities is SDK fidelity. They want to make sure that, to the greatest extent possible, code written for Android 1.5 can run on Android 2.1 without modification. This limits them in two ways. First, they cannot just change the existing Gallery, for example, to accommodate your desires, if doing so causes them to break their existing API. Second, the core Android team will not expose new methods or classes, even if those might be beneficial to third-party developers, unless and until the team is ready to support those methods or classes for the long haul.

Android was initially written before an SDK existed. That's the reason given for why most of the built-in applications (e.g., calculator) cannot be built with the SDK alone, but needs to be built as part of a firmware image. Similarly, the core Android team had to make a decision, as part of creating the initial SDK, of how best to take the existing code and create public stuff we can work with and protected/private stuff we cannot, with SDK fidelity in mind. As you may have noticed, Android is vast, and so creating the SDK must have taken a correspondingly vast amount of staff time. Rewriting lots of it to increase the odds that somebody could, say, create a vertical Gallery wasn't probably high on their list.

In an ideal world, yes, we would be able to more readily extend built-in widgets and significantly modify their behavior. Similarly, in an ideal world, I would have hair... :-)

这篇关于安卓:垂直画廊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆