preference

ActivityNotFoundException when different package's targetClass in PreferenceScreen

左心房为你撑大大i 提交于 2019-11-27 23:35:00
The application's default package is "example.app". and the target activity's package is "example.app.abc". Calling startActivity() for "example.app.abc.TheActivity" in java code just works, but specifying it on preference.xml doesn't work: <PreferenceScreen android:key="key" android:title="@string/title" > <intent android:action="android.intent.action.MAIN" android:targetPackage="example.app.abc" android:targetClass="TheActivity" /> </PreferenceScreen> I tried android:targetClass="example.app.abc.TheActivity" but it doesn't work too. Is it impossible to start an activity of non-default

Define Default Activity (when app starts) programmatically

試著忘記壹切 提交于 2019-11-27 14:21:53
问题 My application is composed by a few activity. Activity A is my main menu with some icons. This Activity can launch depending on which icon you press: Activity B,C,D,E or F. That's fine and really easy, Activity A is the default one. Now, I made an option in preference that allow users to start their favourite activity. Some users will in fact prefer to get directly Activity B for instance. The only way I found a solution was to do this in Activity A This solution is very ugly because Activity

Dynamic ListPreference in android

◇◆丶佛笑我妖孽 提交于 2019-11-27 11:06:44
How to generate dynamic listPreference in android? I want to get all wifi access points and make a list using in preference Activity(i.e. make a list using listpreference). How to do this? Philio Every XML element in Android can be created programmatically as the element name is also a Java class. Hence you can create a ListPreference in code: CharSequence[] entries = { "One", "Two", "Three" }; CharSequence[] entryValues = { "1", "2", "3" }; ListPreference lp = new ListPreference(this); lp.setEntries(entries); lp.setEntryValues(entryValues); You could alternatively create it in XML then add

How to set the Default Value of a ListPreference

被刻印的时光 ゝ 提交于 2019-11-27 04:33:15
问题 i need to set the defult value for a ListPreference when the Activity starts. I've tried with ListPreference.setDefaultvalue("value"); but it makes the firts Entry of the List as default. I need it because i must check a condition and set as default the value which satisfies that condition, so I think it can't be done from the xml file (with android:defaultValue ) For example, suppose I have this array of values in the arrays.xml: <string-array name="opts"> <item>red</item> <item>green</item>

creating a DialogPreference from XML

淺唱寂寞╮ 提交于 2019-11-27 03:39:31
I have been attempting to use an android.preference.DialogPreference inflated from XML, but the documentation seems to be missing some essential bits, and I cannot find a working example anywhere. My XML now looks like this (I tried many permutations but this seems like a reasonable minimum): <DialogPreference android:key="funThing" android:title="Fun Thing" android:dialogLayout="@layout/fun_layout" android:positiveButtonText="OK" android:negativeButtonText="Cancel" /> My supposition at this point is that it is required to subclass DialogPreference and not to use it directly. For one, I cannot

Android: How to adjust Margin/Padding in Preference?

早过忘川 提交于 2019-11-27 01:42:42
问题 Before I asked to remove the padding of the PreferenceActivity/PreferenceFragment: Android: How to maximize PreferenceFragment width (or get rid of margin)? This time I having trouble adjusting margin/padding before Title Text. (See image below). Does anybody have any idea? 回答1: You could customize you checkbox like this: MyPreference.xml <CheckBoxPreference android:key="testcheckbox" android:title="Checkbox Title" android:summary="Checkbox Summary..." android:layout="@layout/custom_checkbox

Android: How to maximize PreferenceFragment width (or get rid of margin)?

…衆ロ難τιáo~ 提交于 2019-11-26 22:45:38
If you look at either Android Settings screenshot or FragmentsBC screenshot, there are margin in PreferenceFragment. How can you get rid of it? I tried making PreferenceFragment width to fill_parent, but no luck. Finally, I found the solution to this. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = super.onCreateView(inflater, container, savedInstanceState); if(v != null) { ListView lv = (ListView) v.findViewById(android.R.id.list); lv.setPadding(10, 10, 10, 10); } return v; } You can set padding by using: setPadding();

Android SeekBarPreference

廉价感情. 提交于 2019-11-26 21:51:20
问题 I'm currently trying to implement SeekBarPreference class using http://android-journey.blogspot.com/2010/01/for-almost-any-application-we-need-to.html tutorial with RelativeLayout. First problem is TextView preferenceText isn't showing at all. Second problem is the bar can't be slided like those in regular preferences (like media volume bar)? public class SeekBarPreference extends Preference implements OnSeekBarChangeListener { public static int maximum = 100; public static int interval = 5;

ActivityNotFoundException when different package's targetClass in PreferenceScreen

拥有回忆 提交于 2019-11-26 21:30:56
问题 The application's default package is "example.app". and the target activity's package is "example.app.abc". Calling startActivity() for "example.app.abc.TheActivity" in java code just works, but specifying it on preference.xml doesn't work: <PreferenceScreen android:key="key" android:title="@string/title" > <intent android:action="android.intent.action.MAIN" android:targetPackage="example.app.abc" android:targetClass="TheActivity" /> </PreferenceScreen> I tried android:targetClass="example

Android shared preferences not saving

隐身守侯 提交于 2019-11-26 20:19:21
问题 I've created an Android live wallpaper and i'm trying to let a user choose an image from their phone and apply it as a background image, but when I launch the activity that start the intent to pick the images, my shared preferences don't seem to save properly. Below is my onCreate method of the activity I start when the users presses the preference button, and the onActivityResult which gets the path of the image on the device (all that seems to work). The println after I commit the