Android :: Simple ListPreference Is Not Working?
Aug 27, 2010
I'm betting im missing one small thing. I've looked on the developer site and i've read some tutorials and i'm just not seeing what i did wrong. I'm trying to use a ListPreference to decide which sound to play on a button click. I have this at the top:
public String greensound;
Here's my OnClick code:
case R.id.green:
SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
greensound = prefs.getString("greensound", "gsone");
if (greensound == "gsone") {
mSoundManager.playSound(1);
} else if (greensound == "gstwo") {...................
View 3 Replies
Aug 28, 2010
I'm trying to use a ListPreference to decide which sound to play on a button click.
I have this at the top:
public String greensound;
Here's my OnClick code:................
I also tried removing the default value here it didnt seem to change anything but, should it be removed?
Here's my Settings.java:
package com.my.app;
CODE:...........
And here's my array's if that will help at all:
CODE:............
Here's a logcat that kinda looked possibly related:
CODE:..........
For those that might ask here's my DDMS > File Explorer > Data > Data > packageName > SharedPreferences This is what was in there:
com.my.app_preferences.xml:
CODE:...................
This all really confuses me more because...It looks like greensound does == gsone so.... I don't understand whats wrong its not even playing the default sound. and yes i've tested all this code without the listpreference code and they work great. I'm not sure what's wrong?
View 1 Replies
View Related
Nov 1, 2009
It is way to slow and in the first example it doesnt even move. How do I make a game? With SurfaceView or OpenGL? And should I draw in a separate thread?
CODE:....................
View 2 Replies
View Related
Feb 19, 2010
I have a basic calculator app I'm making. Two activities, the main one and ResultView.
I've made it where I click a button on activity A to go to activity B. The log says activity B is started and "displayed" successfully, the title for the new activity loads, but the body does NOT show. I added a simple Text view with static text.. see the result.xml at the bottom. I also tried inserting information programmatically, but that didn't do.
When I debug the program, I tried putting breakpoints as the activity is called with startActivity() as well as on the first line of the onCreate method within the ResultView class (my activity "B") but the program never hits the second breakpoint. In fact, it looks as if Looper.class is called in the end.
This bit of code is placed in the button handler on acitivity A:
CODE:........
The activity is in the manifest, within the "application" tag:
CODE:....................
If more info is needed, let me know...in short, "HELLO WORLD" does not display at all.
View 2 Replies
View Related
Apr 17, 2014
I am not able to insert entries in the database. For the record, this was working previously, but I went a few weeks without working with it and now it just doesn't work anymore.
Here is the code where I insert the new row:
Code:
//this is the code where I try to insert the data
dbAdapter.open();
dbAdapter.EnterCreateHistory(DatabaseAdapter.WALKER_HISTORY_TABLE, "fdfsf", "fdfsf1", "fdfsf", "fdfsf", "fdfsf");
[Code]....
The thing is, I am not getting any exceptions or anything. It's just that my number of inserted rows always comes out as 0.
View 5 Replies
View Related
Jul 9, 2010
just wondering if theres a simple guide to follow to get app2sd working? rooted but just wanna get that working lol any help is appreicated :>)
View 2 Replies
View Related
Oct 2, 2009
When using a PreferenceActivity to do preferences, the PreferenceScreen can contain a ListPreference. A ListPreference has an array of keys and an array of values. But the PreferenceActivity only writes the values to SharedPreferences. How do I get the key of the item selected from the list? I would have thought this is pretty fundamental, especially if you want to translate your app.
View 13 Replies
View Related
Mar 25, 2010
I'm using listpreference in my android app and getting my key values and all is well and works good (now that you guys have helped me) BUT - when my listpreference menus popup, they only contain a cancel button. Let's say the user is choosing between red, blue, and green. When the listpreference dialog first pops-up, the dialog only shows a cancel button. Because of that, the dialog disappears as soon as the user selects their choice. I would like it so that when the user chooses their setting, they see the radio button get highlighted and then they go ahead and click the ok button...but I don't have an ok button and can't figure out why.
View 1 Replies
View Related
Aug 7, 2010
Is there a way to use a custom row for the ListPreference in the Android preference screen? Currently I populate the ListPreference like this, but I need more info (description) shown in the List
int count = items.size();
CharSequence[] entries = new CharSequence[count];
CharSequence[] entryValues = new CharSequence[count];
for (int i = 0; i < count; i++) {
entries[i] = items.get(i).toString();
entryValues[i] = String.valueOf(i);
}
langPref.setEntries(entries);
langPref.setEntryValues(entryValues);
View 1 Replies
View Related
May 28, 2010
I want to put a ListPreference in my preference screen. But all the examples I have found in Internet the content are loaded out of a xml and I need that de options in the ListPreference are dynamic and not previously defined (in a xml).
I have mi preferences.xml in the folder xml/ of my project;
this is the code of preferences.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android
View 4 Replies
View Related
Mar 6, 2010
I have an XML preferences screen which is handled by addPreferencesFromResource. On it, there is a ListPreference, for which I want the summary to contain the current value of that preference. I think this would be a common requirement, as otherwise you could not see the present value of the preference without expending a click. I read that the summary field supports resource references, and I see that I can refer to preferences as android:summary="@+preference/prefname" in my ListPreference. Clearly this is why resource references would be supported in this field. However, when I try this, instead of the present value of prefname, the text "false" appears as the summary. Does anybody know how to display a current value without taking the seemingly ridiculous step of rewriting the entire (large) preference screen in Java?
View 5 Replies
View Related
Sep 22, 2010
I'm trying to set a defaultValue to a ListPreference item. Here is an sample of my preference.xml file:
<ListPreference android:key="notification_delai"
android:title="@string/settings_push_delai"
android:entries="@array/settings_push_delai_human_value"
android:entryValues="@array/settings_push_delai_phone_value"
android:defaultValue="????">
</ListPreference>
The two arrays:
<string-array name="settings_push_delai_human_value">
<item>every 5 minutes</item>
<item>every 10 minutes</item>
<item>every 15 minutes</item>
</string-array>.............
View 1 Replies
View Related
Jan 17, 2010
This is my first Android app (which is a soft keyboard, with dvorak layout) and so far it has gone pretty smoothly (either because or despite working from the sample code). I've had some problems (with special/swedish characters) that I've managed to take care of, but this problem I can't figure out how to solve..
But when I click the list item to edit it, i get an empty dialog (Title and button is shown right and with the text I set in the xml- file, but no list, screenshot: http://i49.tinypic.com/2501p55.png ). I can't see any problem with the program code (which isn't many lines..) or the xml (the arrays are generated by the Android utils in Eclipse and the preferences is a mix of auto and manual). You can see both Java code and XML here: http://pastebin.com/m4c52c3a2 (titles etc in Swedish..) (I've also tried a EditTextPreference item, which seemed to work fine..) I have also looked at the log/output using adb, and can't see any problems there either, so I have no idea onto how to solve this.
View 2 Replies
View Related
Mar 21, 2010
I am resuing ListPreference for a setting which I store in the database. I do not want it stored in the preference file. How can I reuse ListPreference in such way that it does NOT save to SharedPreference file?
View 2 Replies
View Related
Mar 23, 2010
I have a settings menu that pops up and in it is a listpreference type menu. It is associated with a settings.xml file where there are 'array-strings' within it. It all works good but I don't know how to retrieve the users preference. As an example, let's say the user picks a color (red, green, or blue). The list that I've made within my 'array-strings' contain the text red, green, and blue. Within my code, I would like to do something if the user has choosen red, something else if they choose blue, etc., etc. Would I use a 'case' statement or an 'if' statement? And most importantly, how would I retrieve the users preference - the key? (am I checking for a boolean?)
View 2 Replies
View Related
Oct 12, 2010
I have a ListPreference with the entries and entryValues correctly set. When I go in the prefernces activity and change the value it successfully works (I added a Toast to output the value after changing the option to test). But when I do the following to compare it, it always executes the else statment when I change it everytime, even like above when I changed the ListPreference and the value was "bluesky" it still failed to execute the correct if statement. Here's the code I use to check the value of the ListPreference in the onResume():
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this)
String backgroundPref = prefs.getString("backgroundPref", "");
if(backgroundPref == "bluesky"){
mainLayout.setBackgroundResource(R.drawable.bluesky);
Toast.makeText(getBaseContext(), "Blue Sky", Toast.LENGTH_SHORT).show();
}else if(backgroundPref == "sky"){
mainLayout.setBackgroundResource(R.drawable.sky);
Toast.makeText(getBaseContext(), "Sky", Toast.LENGTH_SHORT).show();
}else{
mainLayout.setBackgroundResource(R.drawable.sunsetscene);
Toast.makeText(getBaseContext(), "Sunset Scene", Toast.LENGTH_SHORT).show();
}
The Toasts are there so I can double check which statement gets executed, and it always seems to be the else one. Am I having a bad day and getting something wrong?
View 1 Replies
View Related
May 30, 2009
ListPreference default is Single-Choice, how to create Multi-Choice?
View 3 Replies
View Related
Jan 6, 2010
I want to have an element in my preference menu that does the following: Show a list of options. Many are selectable Maximum amount of options to be chosen 2. Possibilities I thought of: Doing a separated PreferenceScreen and showing options as checkBoxes but I don't know where to place the logic of max 2 options. Extending DialogPreference and doing it by hand.
View 2 Replies
View Related
Mar 2, 2010
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.
View 1 Replies
View Related
May 14, 2010
I have created an account type using the AccountAuthenticator stuff as done in the SampleSyncAdapter tutorial. I am now trying to get account preferences working. I have added the line android:accountPreferences="@xml/account_preferences" to my account-authenticator and account_preferences.xml looks like so:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/alum_settings_title"/>
<CheckBoxPreference
android:key="sync_alum"
android:title="@string/sync_alum"
android:summaryOn="@string/sync_alum_check"
android:summaryOff="@string/sync_alum_nocheck"/>..................
View 5 Replies
View Related
May 29, 2010
I'm setting out to create a settings activity for my app. I've defined a PreferenceActivity with a nice layout including a ListPreference object for the user to select a bluetooth device. I'm having trouble dynamically populating the list. I would like to populate ListPreference with values from an array adapter (which I'll create and populate with relevant bluetooth device names). If this were a spinner View, I could just call setAdapter(). However with the ListPreference object I can't figure out how to attach an adapter (findviewByID won't cast from View To ListPreference, so I can't even get a handle to the object). I would like to attach an adapter and then populate the adapter with values, which in turn would populate the ListPreference with values.
View 1 Replies
View Related
Aug 10, 2010
I am trying to create a preference dialog window that allows the user to select more then one item in the list. Currently it only allows you to select one item. Is there an easy way to do this? I have looked all over the internet and not seen a way as of yet.
View 1 Replies
View Related
Nov 24, 2010
How can i add, 4-radiobuttons and 2-checkBoxes in the same ListPreference in Android PreferenceScreen in android?
View 1 Replies
View Related
Apr 24, 2010
Is it possible to define a ListPreference in Xml and retrieve the value from SharedPreferences using getInt? Here is my Xml code...
And I want to get the value with something like: int val = sharedPrefs.getInt(key, defaultValue).
At the moment I have to use getString and parse the result.
View 1 Replies
View Related
Aug 29, 2010
on implementing a multi-select (check boxes) ListPreference on Android? Would I have to extend the ListPreference? Is there any classes already documented to do this?
View 1 Replies
View Related
Oct 13, 2010
Basically im trying to create a simple gui or a layout for android, and I'm really new to Android developing. I already found a way to create a list of stuff using ListActivity, and using the command Code...
View 2 Replies
View Related
Jun 3, 2010
I've tried astrid, and google, and syncing astrid with RTM (free version), and other to-do lists and calendars. I'm just looking for a simple agenda app, where I can click on a damn date and add a list of stuff I want to do without all the mess of prioritizing, adding times, colors, drops of blood, etc. I just want to click and type and have it there, laid out in a simple organized view. possibly a widget. does anyone know of anything like this? Or could someone create one? Not everyone needs an overcomplicated mess.
View 1 Replies
View Related
Jul 24, 2010
I need to save my bank account numbers, passwords and some credit card numbers. I do not need an app that is all that high tech and complicated. I would just like something that is protected via a password so that if my phone is lost/stolen the finder cannot access this information. I tried Keepass but I didn't really like it as I was unable to change the entry fields, ect. It would be nice to have the ability to have this information backed up somewhere.
View 10 Replies
View Related
Nov 17, 2010
I have been trying to reuse the tutorial on the Android developer website about developing a TabActivity App but, unfortunately, it never worked, even when I constructed it the exact same way as it is described...
Using the debugger it seemed the problem came from the main layout.
-> setContentView(R.layout.main); //After this line the app stops.
Here is my main.xml:
CODE:.............................
View 1 Replies
View Related
May 28, 2010
I haven't seen any docs on using the new ContactsContract API. Can someone please direct me to an example/explanation of using it?
View 1 Replies
View Related