Android: vertical gallery?

I am looking for a widget that behaves like gallery widgets but scrolls vertically, not horizontally. I googled everything around, and apparently the answer is that such a finished widget does not exist.

So, I said it myself, well, I'll look at the gallery class in the android source and change it to scroll vertically. Not so easy. The Android SDK is great for hiding (for obvious reasons, to support the structure), but it is also very difficult to extend the widgets. For example, the gallery class uses many member variables from its parent AbsSpinner (mSelectedPosition, etc.) and the parent parent element, etc., which are not accessible from the point of view of the development application. Without access to this member variable, I cannot use the same code from the gallery class for my own use.

Without reaching the inheritance chain and putting the source code of these parent classes in my project or writing the widget from scratch, without using existing infrastructure widgets that have already solved the problem, I can’t find a way to get a vertical scroll gallery.

Is there a better way? Why does the android structure make widget extension so complicated?

+6
android android widget
source share
1 answer

Is there a better way?

Since we do not know what you are building, it is impossible to say. I agree with Yoni Samlan's comment that ListView may be enough for your needs.

Why is the Android framework an extension of such a complex widget?

While it is possible that an overridden Gallery might make it easier for you to orient yourself in a different way, the core Android team should weigh such a re-evaluation against other development priorities.

One of the priorities is fidelity to the SDK. They want to make sure that as much as possible the code written for Android 1.5 can run on Android 2.1 without change. This limits them in two ways. Firstly, they cannot simply modify the existing Gallery , for example, to satisfy your desires, if this leads to the fact that they violate the existing API. Secondly, the main Android team will not disclose new methods or classes, even if they can be useful to third-party developers, unless and until the team is ready to support these methods or classes for a long time.

Android was originally written before the SDK was. This is because most embedded applications (for example, a calculator) cannot be built with the SDK only, but must be created as part of the firmware image. Similarly, the core Android team had to make a decision, as part of creating the initial SDK, about how best to use the existing code and create public materials that we can work with, and protected / private things that we cannot, given fidelity SDK As you may have noticed, Android is extensive, and therefore the creation of the SDK should have required a significant amount of staff. Rewriting a large amount of it to increase the likelihood that someone could, for example, create a vertical Gallery , was probably not high on their list.

In an ideal world, yes, we can more easily extend the built-in widgets and significantly change their behavior. Similarly, in an ideal world, I would have hair ... :-)

+12
source share

All Articles