How would one implement a NumberPicker in Android API 7? - android

There's a NumberPicker widget in API 11, but I'm building for a minimum API of 7. How would I go about implementing one? Is there a custom widget that I can use, or is there a way to get at the components that make up DatePicker / TimePicker?

I find this one very good and flexible given that there were few ready made options available at that api level at the beginning of 2012 when this question was asked.
http://code.google.com/p/android-wheel/
EDIT:
So what if IOS has a similar looking control. That does not make this answer bad. Android is about freedom of choice. Besides, the look of this control is dependent on styles. Take away the shadow, add blue highlights and it looks identical to the Android 4 time picker which is what the OP was asking for.
I am pointing to a possible solution to a persons problem. I am NOT advocating that Android apps should look like IOS apps and I personally hate Android apps that are badly ported so they are a clone of their IOS versions. Some people really are fanboys.

copy the NumberPicker's code in API11 to your project.
xuyao's post doesn't work. The NumberPicker has API11-dependencies (android.animator.*) which cannot be easily replaced. You have to take one of the given libraries.

Perhaps this DigitSpinner class is useful...

copy the NumberPicker's code in API11 to your project.

Related

Android Material Design Components Sample

I'm new at material design. I'm working on some projects and I want to use the material design. But I cannot find any source or sample for components. Is there any code sample (especially animated circle loader)?
Thanks a lot!
There are tens (if not hundreds) samples regarding ways to implement Material Design, some of 'em even described how you could make it work for older versions of Android.
This blog post by Google's own Chris Banes regarding AppCompat v21 is a good place to start when you're also working on Android versions lower than Lollipop.
While this, still from Mr. Banes, thoroughly describe one of Lollipop's most famed API, Palette.
Moving on, this blog post would help you started with those shiny round buttons (or FABs) and, as a bonus, a trick to apply ripple effect to it.
I think those three links should be more than enough to get you started making Material apps - I've built mine and those three were my first guides. Sadly though, I can't find one that matches exactly with your Dribbble link. Then again, I doubt a widget such as those exists today. I've been wrong before though. :)
Hope this helped!
Learn more:
Modular and customizable Material Design UI components for Android
Git link:
https://github.com/material-components/material-components-android
Playstore link:
https://play.google.com/store/apps/details?id=io.materialdesign.catalog

Should we design for Android L Material theme yet?

I just started designing my app for Android L Material theme. I understand that we have to first check whether our existing apps work fine with the ART, the new WebView and all that, but going a step further I want my app to be release-ready when Android L is officially released. But I see that there's very little documentation and I'm not able to get around to find answers to some questions I have -
Is the material theme itself going to be available for older versions of Android?
Is the Android L SDK that's publicly available right now good enough to start building apps using it? I found a few posts on stack overflow where commons guy has said to hold off until Android L is released.
There are a few things that are mentioned in the design specs but there's no documentation on it. Like "Toolbar", for example, is replacing the "ActionBar" according to Google IO 2014 App's source. But why is it not mentioned anywhere in the Android L getting started page? And is it going to be backward compatible with older versions through support library?
Any sample code on how to achieve extended app bar as mentioned in this page?
Is the material theme itself going to be available for older versions of Android?
There have been some comments from Google suggesting that they'll be doing some things in this area. Not everything is strictly possible to offer in the form of a backport. Hence, we won't really know until they ship.
Is the Android L SDK that's publicly available right now good enough to start building apps using it? I found a few posts on stack overflow where commons guy has said to hold off until Android L is released.
The reason for my advice is that we have no idea how stable the L APIs are, particularly with respect to Material Design. If you want to experiment with L for that sort of thing, great! But I'd leave such stuff on a development branch until the next shipping version of Android.
But why is it not mentioned anywhere in the Android L getting started page?
There are lots of things not mentioned in the docs, particularly in API level release notes. That's normal for Android, and it is why I and others write blog posts like this one and this one.
And is it going to be backward compatible with older versions through support library?
That has not been announced. We'll find out when the next production version of Android ships.
Any sample code on how to achieve extended app bar as mentioned in this page?
I am not aware of any, though I haven't been keeping an eye out for it either. My personal aesthetic says "yuck" for that particular aspect of Material Design. :-)

Can we use EffectFactory Class for lower versions

For my new assignment, I wanted to use some library that can provide a "Posterize effect". I found many library like Aviary SDK and jhlabs, Yes, these are easy to use, but these making the code heavier. SO I keep searching for Android's API itself which can do the similar task. And after a lot of RnD, I finally found one my time saver class EffectsFactory which provides the same as I wanted. I applied it in my assignment also. But the bad thing it was added in API level 14, And my app should be compatible with at least API level 8.
So, My question is,
Can I use EffectsFactory class for lower version? If Yes then How?
Or, If No, Then Do we have any API in Android SDK itself which do similar to effectfactory ?
Please avoid referencing any library or NDK's open cv library.
No, there is not an Android API that will posterize an image below API 14. Even above API 14 EffectsFactory may not work, as it says in the Android documentation:
Some effects may not be available on all platforms, so before creating a certain effect, the application should confirm that the effect is supported on this platform by calling isEffectSupported(String).
However, you could easily make a lightweight solution yourself. Posterization is a simple process. For example, the code behind JHlabs' posterize filter is less than 50 lines (and most of them are sugar). In your shoes, if using a 3rd party library was out of the question, I wouldn't hesitate to write my own.
Edit: If you happen to be posterizing images your app takes from the camera, there is also Camera.Parameters.setColorEffect(), but again this is not supported on all devices, as it says in the documentation:
For example, the application should call getSupportedColorEffects() before calling setColorEffect(String).

Android Notepad tutorial: Still "State of the art"?

I am going to make my first app for android (no fear it's just a school project and won't be another useless app in the market :>).
So, before starting this task I did some tutorials, one of these (and which I thought would be very useful, because of the sqlite part) was the Notepad Tutorial. While working through it I saw it was originally designed for Android 1.8 or something (certainly it still worked on my android 4.1).
What I'm really wondering now is:
Is this code still "state of the art" in android programming (especially sqlite, but also the rest :) or is it "deprecated"? If so, can you point me to something newer and better?
Thank you.
SQLite is definitely still the database available by default on every Android device. Also, the basics covered in this tutorial still apply to any Android version. Of course, every new version of the OS also provides new possibilities as to which controls you can use or other new APIs, but for very simple applications, this tutorial is still valid.
I skimmed the article; most of its content seem to be valid for Android 4.x.
Although I don't think the tutorial mention fragments anywhere : they were introduced with Android 3.0.
I think that an important exercise after this tutorial is to read the fragment documentation; have a look at some samples (like the gallery app) and rewrite the notepad in order to use fragments.
You will have to use the Support Library in order to use fragments if the minimum version of Android supported by your app is inferior to Android 3.0 but I think it is also an interesting exercise.
A little tip : many beginners (and experienced devs also :) ) mistakes come from adding a new element in an app but forgetting to declare it in the manifest.xml.

Summary of changes for each API level?

As the title says, are there any sources (web pages etc) of summarised changes at each API level?
I have an app which I've put out to a small group of beta testers and I already fell foul of Context.getExternalFilesDir(), which I hadn't noticed was introduced in API Level 8, when a couple of the guys tried it on Android v2.1 devices.
The majority of my code should be pretty generic but it would be useful if I could find a condensed/summarised list/table or similar that I can quickly glance over.
The Android docs provide a diff between each major API revision. For example, here is the diff between API 10 and 11. Unfortunately, it looks like it's only sequentially available between revisions (not from 8 to 11). I can't find the landing page for the diffs, but you can change the API revision in the URL to see other reports.
You should be running the app yourself on the lowest version of the platform you are supporting. Always. Run it in the emulator. There is no replacement for doing this.
At a glance quick overview: https://developer.android.com/reference/android/os/Build.VERSION_CODES.html (quite well hidden, Google!). Clicking on a particular version will show a more detailed, but still quick overview on what's changed.
Not sure if this is exactly what you're looking for, but I have a look at the the API Overviews when a new version is out. It's a good start to see whats important and new. For example:
Android 2.3:
API Overview
Android 2.2:
API Overview
I also like to take a glance on the Platform Highlights when available.
Here is the analysis of changes performed with the help of the JAPI-CC tool: http://abi-laboratory.pro/java/tracker/timeline/android/

Categories

Resources