Obsolete
Status Update
Comments
ke...@gmail.com <ke...@gmail.com> #2
+Chris/Adam
va...@gmail.com <va...@gmail.com> #3
This is in fact an important problem for ActionBarCompat.
One cannot add any other action item when SearchView is included in always-expanded mode.
Having attribute app:showAsAction="always|collapseActionView" for searchView and calling MenuItem.expandActionView() in code as a workaround doesn't really have the same effect.
Please review its priority.
Forcing the user to use SearchView with 2 taps decreases the quality of user experience on our part.
One cannot add any other action item when SearchView is included in always-expanded mode.
Having attribute app:showAsAction="always|collapseActionView" for searchView and calling MenuItem.expandActionView() in code as a workaround doesn't really have the same effect.
Please review its priority.
Forcing the user to use SearchView with 2 taps decreases the quality of user experience on our part.
df...@gmail.com <df...@gmail.com> #4
I agree with #4.
dk...@gmail.com <dk...@gmail.com> #5
[Comment deleted]
pa...@gmail.com <pa...@gmail.com> #6
[Comment deleted]
eu...@gmail.com <eu...@gmail.com> #7
Additional information that can be useful:
The issue only happens when SearchView is included in ActionBar menu.xml and setIconifiedByDefault(false) is applied.
SearchView item definition from menu.xml:
<item android:id="@+id/menuSearch"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always"
android:title="Search">
</item>
Including SearchView as custom view works correctly, like in this scenario:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SearchView searchView = new SearchView(this);
searchView.setIconifiedByDefault(false);
getActionBar().setCustomView(searchView);
getActionBar().setDisplayShowCustomEnabled(true);
}
The issue only happens when SearchView is included in ActionBar menu.xml and setIconifiedByDefault(false) is applied.
SearchView item definition from menu.xml:
<item android:id="@+id/menuSearch"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always"
android:title="Search">
</item>
Including SearchView as custom view works correctly, like in this scenario:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SearchView searchView = new SearchView(this);
searchView.setIconifiedByDefault(false);
getActionBar().setCustomView(searchView);
getActionBar().setDisplayShowCustomEnabled(true);
}
al...@gmail.com <al...@gmail.com> #8
It's the same for ActionBar not only ActionBarCompat.
ks...@gmail.com <ks...@gmail.com> #9
Ditto this is an ugly bug. It prevents this use case:
- search is done via a REST API whenever someone types a character in
- search takes a while to happen so we should display a progress indicator to user so they don't kill the app because it's not responsive
2nd step is impossible :-(
- search is done via a REST API whenever someone types a character in
- search takes a while to happen so we should display a progress indicator to user so they don't kill the app because it's not responsive
2nd step is impossible :-(
an...@gmail.com <an...@gmail.com> #10
This really should be fixed!
th...@gmail.com <th...@gmail.com> #11
[Comment deleted]
th...@gmail.com <th...@gmail.com> #12
Same problem over here, please fix! Android 2.3.7
al...@gmail.com <al...@gmail.com> #13
Bloody annoying bug.
I found this to be the only workaround so far; onCreate() of my Application (main activity);
// These two lines are working around an android bug:
//http://code.google.com/p/android/issues/detail?id=6641
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.edit().putBoolean(REFRESH_COUNTER_PREF, prefs.getBoolean(REFRESH_COUNTER_PREF, true)).commit();
I found this to be the only workaround so far; onCreate() of my Application (main activity);
// These two lines are working around an android bug:
//
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.edit().putBoolean(REFRESH_COUNTER_PREF, prefs.getBoolean(REFRESH_COUNTER_PREF, true)).commit();
jo...@gmail.com <jo...@gmail.com> #14
This bug is a nuisance indeed.
The mentioned workaround will do the job, and is really only necessary for boolean initializations to "false" (not needed for "true").
If the preferences are bound to evolve a lot, then it's probably safer (to prevent human error) to re-parse the preferences XML manually to pinpoint the booleans that are still null and properly initialize all of them.
The mentioned workaround will do the job, and is really only necessary for boolean initializations to "false" (not needed for "true").
If the preferences are bound to evolve a lot, then it's probably safer (to prevent human error) to re-parse the preferences XML manually to pinpoint the booleans that are still null and properly initialize all of them.
al...@gmail.com <al...@gmail.com> #15
Is that right? I spend a good half hour trying to initialise my pref to true with no luck, setting defaults didn't seem to work, so what's the "fix" for that case? As you can see, my fix above is setting it true.
jo...@gmail.com <jo...@gmail.com> #16
Just to make sure: when you call "PreferenceManager.setDefaultValues()" please ensure that you set the 3rd argument to "true". If you don't, newly added values won't get initialized at all.
Regarding the bug, personally I have seen it happening (but only with "false") on HTC Hero, Nexus One, HTC Sensation, Galaxy S2, Galaxy Nexus. On which device/firmware did you see the issue happening with "true"?
Has anyone looked at AOSP source code for this? Maybe the bug is obvious. I would be surprised if any manufacturer had modified that part of Android's code, except perhaps for fixing the bug.
Regarding the bug, personally I have seen it happening (but only with "false") on HTC Hero, Nexus One, HTC Sensation, Galaxy S2, Galaxy Nexus. On which device/firmware did you see the issue happening with "true"?
Has anyone looked at AOSP source code for this? Maybe the bug is obvious. I would be surprised if any manufacturer had modified that part of Android's code, except perhaps for fixing the bug.
al...@gmail.com <al...@gmail.com> #17
[Comment deleted]
al...@gmail.com <al...@gmail.com> #18
Apologies, after a data clear which it appears I missed initially, testing this on the Desire Z 2.2.1 with the following line appears to have solved my problem with an initialisation of "true";
PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
For those visiting, this apparently does not solve the "false" value initialisation, which I assume, by default is designed not to write out a preference for a false.
My question, is this "false" initialisation problem existent for both an explicitly "false" preference after using the above line, or for the "assumed" implicit initialisation?
PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
For those visiting, this apparently does not solve the "false" value initialisation, which I assume, by default is designed not to write out a preference for a false.
My question, is this "false" initialisation problem existent for both an explicitly "false" preference after using the above line, or for the "assumed" implicit initialisation?
jo...@gmail.com <jo...@gmail.com> #19
Thanks! Glad to know that it's the same for everyone (ie: the bug only happens with "false").
The problem only happens for preference keys that you want to initialize *explicitly* to "false" in the XML. It works for "true" but not for "false". If you initialize it from onCreate() in the java code, it works for both "true" and "false".
If you don't initialize the preference key (neither in the XML nor in code) then it remains "null". There is no implicit initialization of any Preferences, afaik.
The problem only happens for preference keys that you want to initialize *explicitly* to "false" in the XML. It works for "true" but not for "false". If you initialize it from onCreate() in the java code, it works for both "true" and "false".
If you don't initialize the preference key (neither in the XML nor in code) then it remains "null". There is no implicit initialization of any Preferences, afaik.
al...@gmail.com <al...@gmail.com> #20
By implicit, I meant that when entering a PreferenceActivity, lists will be "none" and checkboxes are "unchecked". Initialised is not exactly the correct term, but I'm sure you follow my point.
For a checkbox I need to be checked as default, this is a problem, for an "unchecked" however, an "uninitialised" is as good as a "false" in terms of visual representation within the PreferenceActivity. And since you would specify a default when loading it for the first time, it shouldn't be a problem, at least for my use case.
For a checkbox I need to be checked as default, this is a problem, for an "unchecked" however, an "uninitialised" is as good as a "false" in terms of visual representation within the PreferenceActivity. And since you would specify a default when loading it for the first time, it shouldn't be a problem, at least for my use case.
jo...@gmail.com <jo...@gmail.com> #21
Oh. Yes, in terms of visual representation in Android preferences it's true that "false" is the same as "null" - but in terms of what the programmer expects, I think that's clearly a bug, as we're explicitly requesting an initialization to "false" in the XML.
Also, some programmers might have strict expectations for boolean preferences if they implement a "three-state" checkbox as in Windows for example: "true", "false", "undefined" (=null). It might be useful! In that case "false" and "null" would have a different graphical representation, and the bug would become visible for end-users too.
Also, some programmers might have strict expectations for boolean preferences if they implement a "three-state" checkbox as in Windows for example: "true", "false", "undefined" (=null). It might be useful! In that case "false" and "null" would have a different graphical representation, and the bug would become visible for end-users too.
ra...@googlemail.com <ra...@googlemail.com> #22
If you use sharedPrefs.getBoolean("Value initialised with false as default",false) you will get the right value. You get a false since the value does not exist yet. If you initialised it as true then you will get true anyways, so this is how you have to do it.
pa...@gmail.com <pa...@gmail.com> #23
Well.. You are parially right. I'll get "false" value, but this won't solve the problem at all.
What I expect from PreferenceManager.setDefaultValues(this, R.xml.settings, true); is to INITIALIZE preferences, so I expect that they are initialized :)
What I expect from PreferenceManager.setDefaultValues(this, R.xml.settings, true); is to INITIALIZE preferences, so I expect that they are initialized :)
gi...@gmail.com <gi...@gmail.com> #24
Don't know if this bug was solved or not. But I find a solution:
on your onCreate() (or onResume()) main activity put those lines
//Get this application SharedPreferences editor
SharedPreferences.Editor preferencesEditor = PreferenceManager.getDefaultSharedPreferences(this).edit();
//Clear all the saved preference values.
preferencesEditor.clear();
//Read the default values and set them as the current values.
PreferenceManager.setDefaultValues(this, R.layout.activity_prefs, true);
//Commit all changes.
preferencesEditor.commit();
on your onCreate() (or onResume()) main activity put those lines
//Get this application SharedPreferences editor
SharedPreferences.Editor preferencesEditor = PreferenceManager.getDefaultSharedPreferences(this).edit();
//Clear all the saved preference values.
preferencesEditor.clear();
//Read the default values and set them as the current values.
PreferenceManager.setDefaultValues(this, R.layout.activity_prefs, true);
//Commit all changes.
preferencesEditor.commit();
ja...@gmail.com <ja...@gmail.com> #25
[Comment deleted]
en...@google.com <en...@google.com>
ta...@gmail.com <ta...@gmail.com> #26
Is this still broken? Are we still forced to live with the workaround?
dm...@gmail.com <dm...@gmail.com> #27
Bump- this is an amazingly huge bug. That or the documentation is causing so many people to run in to this problem that it is buggy. Is there really no movement here since 2011?
ap...@gcorsini.com <ap...@gcorsini.com> #28
Hi everyone
This is really annoying! For now I just add the line proposed byalias.ne (http://code.google.com/p/android/issues/detail?id=6641#c12 ) at the start of each app I write, when I need a CheckBoxPreference. I had that problem on Android 4.2.2.
The Status "Obsolete" is a real joke!
Have a nice day.
This is really annoying! For now I just add the line proposed by
The Status "Obsolete" is a real joke!
Have a nice day.
am...@gmail.com <am...@gmail.com> #29
I am facing the same problem. Why is this issue marked as obsolete?
za...@gmail.com <za...@gmail.com> #30
Looks like the issue still persists. Targetting API 15 with support v7.
Description
<CheckBoxPreference
android:defaultValue="false"
android:title="@string/text_enabled"
android:key="lol" />
When i do :
preferences = PreferenceManager.getDefaultSharedPreferences(this);
PreferenceManager.setDefaultValues(this, R.xml.settings, true);
All preferences should be initialized (not REinitialized) to their default
values, no ?
On Android 2.0 (2.1 on my Nexus One), it's not working with
CheckBoxPreference/boolean
They are not initialized.
All other preference type are ok
This bug is not on Android 1.5.