I'm currently working on an Android app, and looking at the PreferenceActivity class and the corresponding layout elements (PreferenceScreen, etc.), it appears that it provides much of the functionality that I desire for a major component of the app. However, that component is not a Settings activity per se, and I'm not sure if using Preference stuff for things that aren't technically preferences is a good way to do things. On the other hand, I'd prefer not having to implement all the features that PreferenceActivity/etc. provides, so would it be fine to use that framework and just change the layout theme so it doesn't seem like a Settings menu?
You can definitely load/set up the preference layout using the android framework and then save the data using your own implementation of SharedPreferences. This class is a good example. Not sure why you would not make it look like a preference screen though. What's wrong with that look?
Related
I'm trying to figure out (if it's even possible) to override the behavior of the built in ICS launcher folders.
I have a specific and small change I'd like to add (simply add a button on the top to sort alphabetically to start with). From looking at the source for Launcher2 add the behavior should be easy enough, but I can't seem to figure out way to hook into the launcher and override specific bits.
I would hazard to guess that the correct approach is that you have to implement a full custom launcher (by altering the class I'm interested in changing and recompiling Launcher2) and that what I'm hoping to do isn't possible. Android/Java is not my day job so I'm hoping there might be a way that I'm not seeing that a more experienced developer is aware of.
In short is/how can I implement a custom subclass of com.android.Launcher2.Folder and have that used instead? Preferably with just a drop in app rather than having to completely override the normal ICS launcher app.
I'm trying to figure out (if it's even possible) to override the behavior of the built in ICS launcher folders.
No, sorry.
I would hazard to guess that the correct approach is that you have to implement a full custom launcher (by altering the class I'm interested in changing and recompiling Launcher2) and that what I'm hoping to do isn't possible.
Correct. Beyond that, you cannot simply reuse their code, as packages have to be unique in Android devices.
how can I implement a custom subclass of com.android.Launcher2.Folder and have that used instead?
Completely rebuild the firmware that contains the modified class, then use that modified firmware on your device. Or, refactor the entire home screen app into your own package, get it building as a standalone app (which may not be easy), and then add in your change.
Far simpler would be for you to make your own app widget that implements some sort of folder construct. That would not "override the behavior of the built in ICS launcher folders", but it could give you the functionality you seek.
Most apps have some kind of preferences or user settings that can be stored via the SharedPreferences. My first implementation of an activity for the user to edit his settings was pretty straight forward: a couple of input fields and a 'Save' Button. This is neither pretty nor easily extensible.
The android system settings and many apps that I have seen tend to layout their preference editing in ListViews.
My second approach tries to imitate this: a ListActivity and every item has to supply it's own layout, since I want to store different types of values (some are numbers, some are boolean radio buttons).
I am finding it rather cumbersome to implement this and now I am wondering if I am missing some obvious design pattern here?
Just use PreferenceActivity, it will build the UI and handle the preferences persistence for you. Here you have more documentation:
http://developer.android.com/reference/android/preference/PreferenceScreen.html
http://jetpad.org/2011/01/creating-a-preference-activity-in-android/
http://www.kaloer.com/android-preferences
I'm trying to get my app to blend in as much as possible with the "standard" with the rest of my android device. It's a stand-alone app, not integrated with the OS or anything, I just want it to look familiar.
The area I'm interested in is the "settings" screen. If I look at Android's standard settings screen, it's well spaced, perfect font size, with neat pin stripes between the menu items.
How do I do that? Is that a ListView? Is it done with a regular LinearLayout?
I would love to be able to replicate the look & feel in my app. Can anybody assist?
And it's not just the Adroid OS. it's most of the "professional" apps out there:
Many thanks
Actually, this is directly part of the Android source code, so I would strongly advise you to take a look in its structure. See the Android Settings tutorial for more info.
Settings are created from the SettingsActivity (which extends the PreferenceActivity, you might want to look this too), which in their turn have their layout based on the following xml files:
preferences.xml
preference.xml
Things are quite strongly interlocked so it needs some reading...
AFAIK its a ListView. by implementing a custom ListView, you can achieve similar effect.
Moreover, you'll have to follow the Icon Design Guidelines to create such icons for ListView rows
When adding a "settings" screen to my app I seem to have come up with two choices:
use the PreferenceActivity that is given by Android
create a standard Activity that saves all the user's choices
Assuming I don't mind writing the code that saves the preferences (a relatively trivial task), what other advantages are there to using a PreferenceActivity? If anything, using a standard Activity provides much more flexibility with regards to UI design.
You are right, given the desired view complexity (which sometimes is not more usable - remember preferences should be easy to set), it might not make sense to implement a PreferenceActivity. The idea is to present a uniform configuration screen & visual style to the user. As such, a user will always know when he entered a preference screen.
From the docs:
Furthermore, the preferences shown will follow the visual style of system
preferences. It is easy to create a hierarchy of preferences (that can be
shown on multiple screens) via XML. For these reasons, it is recommended
to use this activity (as a superclass) to deal with preferences in applications.
The docs say something about inflated views, maybe you could investigate whether complex layouts or custom views can be integrated.
I came across this app and I wonder how was it developed on android (Cause it looks so much like an iphone app), see this screenshot.
Anyone have any idea how to accomplish that type of look on Android?
That's just a matter of styling after all. In general, I would consider it to be discouraged to make your Android app look like an iPhone app. Every platform has its own UX standards, and Android's standards are different from iPhone's. That quite obviously also reflects in the user interface.
Anyhow, you may want to read this article about Android themes and styles. It should get you going with defining own widget styles and stateful drawables to implement custom buttons.
This app obviously uses customized ListViews, ButtonView on the bottom of the screen.
Theses are pretty much standard and common in android apps.
Here is how to create custom components:
https://developer.android.com/guide/topics/ui/custom-components.html