I have an Android settings screen (i.e. using classes related to the Preference class) where the user can configure 3 different colors. Each color is stored as an integer using the shared preferences functionality.
I want to let users save and restore the colors chosen (i.e. color schemes). At the top of the settings screen, I want a button that pops up a list of all current saved color schemes. Picking a color scheme would set the 3 color settings to the colors for that color scheme. If the user chooses to save the current colors, they are asked to name the color scheme and this color scheme will then appear in the color scheme selection list.
What's the simplest way to implement this functionality?
I think using the Android built-in SQLite database is your best option. You can create an SQL table colorscheme with 4 columns: id, color1, color2, color3. Then query the SQLiteDatabase.query method.
Have a look at the NotePad example at http://developer.android.com. Or at this tutorial.
Related
I cannot seem to find any details on what these colours are supposed to indicate or be related to.
As far as I can tell they don't appear to correlate to anything, and multiple instances of the same MBean interface have different colours assigned to the same attributes.
Those colors will be used if you add the attributes to a charts (right click on an attribute and click "visualize").
Like Alexandre says, they are used in the charts.
If you add an attribute to a chart, you can right-click in the chart legend and choose to change the color for that attribute, this will also update the color on the MBean Browser page.
If no specific color is set, we will just use hash value of the attribute object to create a color, so that's why the colors appear very random.
I am pretty new to Android / Java App development and wanted to ask,
the best way to save the app condition.
In my case I have two buttons, which have a default color of red.
When the user clicks on each of them it gets the color of blue.
What's the best way to save this condition?
So that the color will not reset to the color of red when I restart the app.
Try to look here.
Principal data storage options in Android:
Saving key-value pairs of simple data types in a shared preferences
file
Saving arbitrary files in Android's file system
Using databases managed by SQLite
I have many TextViews created programatically, but I cannot find out how I could change the text size according to what screen size the device is.
Example: I have layout_sw300dp and layout_sw600dp folders containing individual screen designs to fit according to the phone used. But since I programatically create TextViews, I cannot alter the TextSize for different screen sizes.
How can I fix this matter? Is it possible to have different /res/values/styles.xml for different screens, that way I can attach the style via code and define the styles individually in XML, if so, what is the folder layout?
If you're setting the text size of the TextView using 'sp' then the text should be automatically scaled.
I am developing a project in which i'm displaying certain checkboxes to user that he may select a few of them as his/her seat as in movie hall or airplane. I want checkbox to be displayed as chairs or some other image how can i do it. The generation of checkboxes is happening in custom tag (java web project)
Please go thro the HTML from below URL. Here background images are applied to checkboxes.
http://webdesign.maratz.com/lab/fancy-checkboxes-and-radio-buttons/demo.html
You may also use the same logic, have two images. One is for before select, during onclick change the another background image.
If you want to do this then u should write a custom java script code for this purpose.
Create image and then associate the states (true / false) with them and when user perform the select(Click) operation on those image then change the state associated with Image.
Here is a link from where u can learn how to implement this
http://homepage.ntlworld.com/vwphillips/ImageCheckBox/ImageCheckBox.htm
I'm creating an app for use by pilots. It mostly uses TextView, EditText, Button, etc. In other words, not very graphics-heavy.
When used at night, I'd like for the user to be able to switch to a "night mode" where everything on screen is red and black... like the Google Sky Map app. (This is important for pilots because the color red does not destroy the eye's natural night vision adaptation as other colors do.)
What's the best way to do this? I found APIs like ColorFilter, etc. but I'm not sure how I'd apply these app-wide.
If you're simply talking about changing the colours of the various views within the layout and not the structure of the layout itself, then I'd suggest you simply do this using styles.
i.e. Define two sets of styles for the various views which make up your layout - one set for night mode and one for day mode. In your activity, it then becomes a case of calling setStyle() on each of your views to toggle it between night and day.
Coming up with a sensible naming convention and parentage scheme for your styles will make your life a lot easier. e.g. MyText.Large vs MyText.Large.Night.
The Android developer doc on Themes and Style is a good starting point.
Creating a day and night theme and setting it programmatically would work. But it also requires you to duplicate your styles, just to specify different drawables/colors.
Instead, you can maintain one style and use Android's built in day/night mode support. Just as you can have multiple variations of a single layout (for landscape or portrait screen orientations,) drawable (for different pixel densities) and string (for different locales,) you can also have day and night versions of your drawables and colors. The specifiers are "-night" and "-notnight" but you will probably want to use "-night" or nothing, making your day version the default. For example:
res/drawable/fancy-button-background.9.png
res/drawable-night/fancy-button-background.9.png
Android should be able to switch the day/night mode automatically but the details on how and when that happens are a little unclear to me. To change the mode yourself, you can use UiModeManager#setNightMode(). Just make sure car mode is enabled first, using enableCarMode(0).