I have an application, where I want there to be several EditTexts on one screen, and then to the right of each, a button that will open a dialog for settings related to that EditText
Issue is, I am trying to do this within a PreferenceActivity.
I know I could just use a preference as a button to open a normal Activity to display the linearlayout (or relativelayout), but that really doesn't satisfy what I need.
I can use an EditTextPrefence in the preferenceActivity, but that's really not preferred (it will work if it has to), and I could just use a DialogPreference with checkboxes in it, but I really like the summary capability of a CheckBoxPreference, so I would rather have a dialogpreference that opens and then shows a PreferenceScreen of CheckboxPreferences.
So, I just need an EditText within a preferenceScreen and a CheckBoxPreference within a DialogPreference
It doesn't seem like this is possible, but if so, any help would be greatly appreciated.
Thank you.
Issue is, I am trying to do this within a PreferenceActivity.
Since it would appear that these are not preferences, please create a regular activity, using EditText and CheckBox widgets. Then, you can design it pretty much however you want.
If, OTOH, these are indeed preferences, then please use the standard Android preference UI, which does not resemble what you are describing. The point behind the standard Android preference UI is for it to be standard, with minor customizations (e.g., creating some sort of color-picker DialogPreference). Your changes do not sound minor.
Related
I have a collection of items which are shown using a ListView.
Each of these items has its own settings. By clicking on one item I want to allow the user to view/change its settings.
What is the best way to do this?
It would be nice if I could use something like PreferenceActivity as this provides a nice layout. Unfortunately the preference mechanism always saves the chosen preferences to a global file (see SharedPreferences).
A workaround might be using multiple files, one per item, but I don't like this solution since the collection is dynamic and I prefer the settings to be local to my objects.
Another workaround might be opening a PreferenceActivity, then reading all the settings and saving them to the appropriate object. This also seems far from elegant.
Finally, I could implement my own activity with a ListView and custom item layouts, but this seems a duplicated work to get the same behavior and style.
Any suggestion is welcome :)
Thank you
I'd do something along the lines of PreferenceActivity, but save the preferences to the items themselves or something associated with them. To display the preferences input, use a dialog Fragment. You can then either pop up the dialog, or display it as a regular Fragment.
I want to create a custom keyboard which will be available in my application only (It's used jut for a single EditText in one activity), and I was wondering what would be the best way to do so. Here are my specifications for the keyboard:
It should always be displayed in the activity it is used (Regardless whether the EditText is focused or not).
It will have 2 or more keys layouts (Similar to the regular keyboard which has letters layout and a few numbers/symbols layouts).
Some keys may require some special action (Rather than simply adding their android:codes key value to the EditText).
It doesn't offer candidates for completion/correction.
It doesn't offer more than one input type (Like the regular keyboard which has TYPE_CLASS_NUMBER, TYPE_CLASS_DATETIME and so on...).
How should I develop it? Should I create a full input method service for it? Or should I create just a KeyboardView and add it to the activity's layout? (I want to use KeyboardView for the convenience of keys creation and click events handling)
Since it's a one-off thing and not meant as a separate app, You can simply use whatever method is easiest for you (The KeyboardView method).
Try it out and make sure it's responsive and snappy. If it works, then simple and easy method would be my recommendation.
Maybe you could take a look at this. I think the best way is to make a custom layout and inflate it. Theres a tutorial given here too.
I'm trying to create a hierarchy of classes which start with a PreferenceActivity.
The idea is the base class contains the 'About Me' button, then the next class implements the generic preferences for games/apps/wallpapers and then the next class adds the the specifics for each actual Game/App.
The idea works well BUT because I'm 'adding' preferences from XML at each level, they appear with the most generic (lowest level) ones first (e.g. my 'About' button).
Ideally I'd like them to be the other way up - so that specific preferences appear at the top of the list and generic ones at the bottom - is there any way of achieving this (I've read through the docs on PreferenceFragments and the new PreferenceHeaders and even that doesn't seem to offer anything?)
Is there any programmatic way to move PreferenceCategorys or PreferenceScreens around within the overall order??
Essentially when I'm using
addPreferencesFromResource(R.xml.clock_settings);
I'd like to have a
addPreferencesFromResourceAtBottom(R.xml.clock_settings);
I'm getting good at answering my own questions here :)
The solution lies in the android:order XML parameter - using that with Preference (or PreferenceGroup or a sub-class of it) will sort stuff into the right sequence on screen!
You could also change this dynamically with setOrder() but it won't reorder the Preferences if they've already been added to a PreferenceGroup.
I am trying to put together a modal box with a scrollable list of checkable items and an OK and Cancel button at the bottom for the user to select filters from. It seems the simplest way to do things like this in Android is to reuse API components (widgets, layouts, etc) and the closest one I can find to this looks to be the ListPreference, which basically does exactly what I want (I can even work with storing the data in SharedPreferences).
The problem is that I'm not launching this modal box from a PreferenceActivity, but rather will be launching it from either of two activities: a ListActivity and a MapActivity. If a ListPreference would be possible here, that'd be really convenient, but otherwise any help getting me in the right direction would be great.
Thanks!
Nick
Try an AlertDialog, supplying it with your ListAdapter via AlertDialog.Builder.
I'm developing my first Android application, and I'd like to create a settings screen.
I'd like the screen to have a similar look-and-feel as the native phone-settings screens and the native "create/edit alarm" screen. Thus with different kinds of (statically defined) items vertically stacked with a thin line between them.
How do I define such screen?
I understand I can use the ListView, but this seems to be primarily meant for serving dynamic data using a ListAdapter, where each item is served in the same format. It seems to be possible to create different items (that is, some with checkbox, some with two text-lines, some with an icon) by creating my own ListAdapter and overriding getView but this seems like overkill. Should I be using a ListView for this purpose?
There's no need to manually create and format a ListView - there are ways in the API to create Preference screens.
The most obvious is PreferenceActivity.
You can define all your preferences in an XML file, a bit like a layout, and then load them with addPreferencesFromResource() or you can create a number of PreferenceScreen objects in code and populate them with Preference objects that way.
The best thing do would be to look at the API Demos application provided with the Android API. This contains lots of good examples of managing preferences. Here's how it creates preferences from code and here's a sample preferences XML file. There are other examples showing more advanced things like preference dependencies and preference listeners.
Actually in the built-in alarm application, for edit and create alarms, there are two activities, one for create and one for edit.
The Create Alarm activity is the first one with the digital clock.
The Edit Alarm activity is started by clicking on a listed alarm from the Create Alarm activity.
Edit Alarm implements PreferenceActivity, but Create Alarm is more complex (custom cursor adapter to list the alarms).
Have a look at the sources:
Create Alarm activity
Edit Alarm activity