default

Android Preferences: How to load the default values when the user hasn't used the preferences-screen?

这一生的挚爱 提交于 2019-11-26 19:26:17
I am using a PreferenceActivity to let the user set some values. I am feeding it the xml file with the defined preferences. I have set all the android:defaultValue="" for them. When I start my application, I need the preferences, or if they are not set yet manually, I want the default values: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean value = prefs.getBoolean("key"), false); However, when android:defaultValue="true" I still get false . So, it looks like the defaultValues set in the XML are not used anywhere but when initializing the preferences

How can I use DB side default value while use Hibernate save?

社会主义新天地 提交于 2019-11-26 19:23:21
问题 I have a column in DB with default value as sysdate . I'm looking for a way to get that default value inserted while I'm not giving anything to corresponding property on app side. By the way, I'm using annotation-based configuration. Any advice? 回答1: The reason why the date column gets a null value when inserting, even though it is defined as default SYSDATE dbms-side, is that the default value for a column is only used if the column is not given a value in the query. That means it must not

Pros and cons of package private classes in Java?

烂漫一生 提交于 2019-11-26 18:51:29
I am learning Java recently, and I came across the notion of package-private classes, which is the default if we don't specify anything. But then I realized: I seldom see the use of package-private class. Is there a reason for this, e.g., it has serious drawbacks, it is redundant, or simply I am not reading enough? Are there strong arguments for/against its usage? If it is really not useful in most cases, why would it be the default? In what situation should we use package-private in the real world? I.e., when would it become irreplaceable? In other words, what are the major pros and cons of

Symfony2 Setting a default choice field selection

巧了我就是萌 提交于 2019-11-26 18:43:58
I am creating a form in the following manner: $form = $this->createFormBuilder($breed) ->add('species', 'entity', array( 'class' => 'BFPEduBundle:Item', 'property' => 'name', 'query_builder' => function(ItemRepository $er){ return $er->createQueryBuilder('i') ->where("i.type = 'species'") ->orderBy('i.name', 'ASC'); })) ->add('breed', 'text', array('required'=>true)) ->add('size', 'textarea', array('required' => false)) ->getForm() How can I set a default value for the species listbox? Thank you for your response, I apologise, I think I should rephrase my question. Once I have a value that I

PHP sessions default timeout [duplicate]

末鹿安然 提交于 2019-11-26 18:43:54
This question already has an answer here: How do I expire a PHP session after 30 minutes? 13 answers Do PHP sessions timeout by default - ie without any coding on my part would a user eventually be "logged out" after some time of inactivity? Niet the Dark Absol It depends on the server configuration or the relevant directives session.gc_maxlifetime in php.ini . Typically the default is 24 minutes (1440 seconds), but your webhost may have altered the default to something else. You can change it in you php-configuration on your webserver. Search in php.ini for session.gc_maxlifetime() The value

How do I set default values for functions parameters in Matlab?

一世执手 提交于 2019-11-26 18:29:35
Is it possible to have default arguments in Matlab? For instance, here: function wave(a, b, n, k, T, f, flag, fTrue=inline('0')) I would like to have the true solution be an optional argument to the wave function. If it is possible, can anyone demonstrate the proper way to do this? Currently, I am trying what I posted above and I get: ??? Error: File: wave.m Line: 1 Column: 37 The expression to the left of the equals sign is not a valid target for an assignment. simon There isn't a direct way to do this like you've attempted. The usual approach is to use "varargs" and check against the number

How to change Android O / Oreo / api 26 app language

时间秒杀一切 提交于 2019-11-26 17:38:14
问题 I want to change the language of the app and this works fine until API 26. For api > 25 I put Locale.setDefault(Locale.Category.DISPLAY, mynewlanglocale); before setContentView(R.layout.activity_main); but nothing changes. The docs don't explain too much about this. 回答1: I had the same problem: since Android 8.0+ some parts of my app did't change their language anymore. Updating of both application and activity context helps me. Here is an example of MainActivity function: private void

Why is default required for a switch on an enum?

爷,独闯天下 提交于 2019-11-26 17:29:00
问题 Normally, default is not necessary in a switch statement. However, in the following situation the code successfully compiles only when I uncomment the default statement. Can anybody explain why? public enum XYZ {A,B}; public static String testSwitch(XYZ xyz) { switch(xyz) { case A: return "A"; case B: //default: return "B"; } } 回答1: The reason that you have to uncomment the default is that your function says that it returns a String , but if you only have case labels defined for A and B then

Does the <html> element have a default margin or padding in any browser, since normalize.css doesn't reset it?

匆匆过客 提交于 2019-11-26 17:18:07
问题 I'm using normalize.css, and I saw that it doesn't reset margins or padding for the <html> element. Since I assume they've done their research I was wondering: does the <html> element have a default margin or padding in any browser? Is it right of me to assume that it doesn't and that this is why normalize.css doesn't reset it? 回答1: The <html> tag does not have any CSS rules automatically applied to it. You can apply styles if you like, but the only time I've ever done it is to get 100%

Should switch statements always contain a default clause?

不羁岁月 提交于 2019-11-26 17:02:00
In one of my first code reviews (a while back), I was told that it's good practice to include a default clause in all switch statements. I recently remembered this advice but can't remember what the justification was. It sounds fairly odd to me now. Is there a sensible reason for always including a default statement? Is this language dependent? I don't remember what language I was using at the time - maybe this applies to some languages and not to others? Switch cases should almost always have a default case. Reasons to use a default 1.To 'catch' an unexpected value switch(type) { case 1: /