android-preferences

Android preferences spinner

别等时光非礼了梦想. 提交于 2019-12-12 07:15:56
问题 How can I build something like this? I wanna open a dialog in the Preferences Activity, where the user can change the number with a spinner, when he clicks on the according preference item. I got the screenshot from Android Developer Tools, but I cannot find some example code. 回答1: I have developed a Custom Preference, which can be found here. XML Code: <com.vanniktech.vntnumberpickerpreference.VNTNumberPickerPreference android:defaultValue="@integer/font_size_default_value" android:key=

How the Activities are kept in preference screen settings

自古美人都是妖i 提交于 2019-12-12 05:23:41
问题 How can activities be saved in listView preferences so that when a User selects an activity in preferences so that when user starts the app next time they will appear as a first screen? 回答1: When user choose an Activity to save on it's preferences,You can save name of that Activity to sharedPreferences. Then in your MainActivity class when app runs again, check for saved activity and start that. see this SO question To save to preferences: PreferenceManager.getDefaultSharedPreferences(context

Android is Crashing on ListPreference

冷暖自知 提交于 2019-12-12 04:43:30
问题 I am trying to get the value after the it is selected in setting preferences dialog. But I get a ClassCastException and a crash? Probably because I'm not sure how to get the value that has been selected and save it. Essentially I need to be able to get the new value in another Activity . How do you get these values and save and be able to find them in other activities? public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { SharedPreferences s =

How to allow clicking on disabled preferences (or mimic disabled preferences functionality)?

a 夏天 提交于 2019-12-12 04:12:51
问题 Background Some app features require permissions. If a permission is not granted, we need the preference of it to be "semi" disabled (and not change if it's ticked or not), with a text telling that it cannot be used because there aren't enough granted permissions, so that it only partially looks disabled (the text will stay black, with the warning being red). It won't look like a normal disabled preference. Like a normal disabled preference, though, when it's in this state, all preferences

how to programatically modify a CheckBoxPreference view

回眸只為那壹抹淺笑 提交于 2019-12-12 02:25:31
问题 How can I change the view of a CheckBoxPreference at runtime? Specifically, I'd like to change a CheckBoxPreference summary depending on whether the user has checked the box or not. If it were a normal view, I could do something like: view1 = (TextView)findViewById(R.id.idView1); view1.setText("some text"); But a CheckBoxPreference has no id, so I don't know how to get a "handle" to it. 回答1: I have an answer to my own question. The key is to use findPreference in a PreferenceActivity , as

ringtone picker is not working

情到浓时终转凉″ 提交于 2019-12-12 02:05:45
问题 i'm using this lib android.v4.preference.fragment, having issue with ringtone preference, the below code works superb for ICS and below version phones, but it launches duplicate ringtone dialog for ICS and above phones, i.e it launches 2 ringtone preference dialogs. ringtonepref.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { // TODO Auto-generated method stub { SharedPreferences settings = PreferenceManager

Add Prefrences Screen to an Activity with a customized window title

自古美人都是妖i 提交于 2019-12-12 01:03:50
问题 I know its possible to add a button to a prefernces Screeen activtiy. I read this question How to add a button to PreferenceScreen and it works perfect. But if I want to add my custom title my application just crashes. The customtitle works perfect in its own activity and the preference screen with button works also perfect in its own activity. So my problem is only based on bringing these two functions together. heres my code in of the java file public class TestHeadlineActivity extends

Android CheckboxPreference doesn't work with Broadcast Reciever

六眼飞鱼酱① 提交于 2019-12-12 00:42:32
问题 I'm trying to disable Wifi when not connect to any network after a min. But getting some problems. When i run the app. It start working and try to disable wifi that's not connect to any network. It's mean I can't stop it. I have a Preference Activity with CheckBoxPreference . It's the setting to turn on/off this feature. I want to only work when user checked the checkbox. If uncheck, stop working. But right now, It's working anytime out of control. CheckBox is doesn't work for turn on/off

Reference a specific item in a <string-array> from a preferences XML?

血红的双手。 提交于 2019-12-11 22:49:58
问题 Assuming I have a string array defined as: <string-array name="settings"> <item>not very unique</item> <item>not very unique</item> <item>slightly more unique</item> </string-array> Is there a way to reference an item, by its index in the array, from a preferences XML? I know how to reference the entire array: android:entries="@array/settings" But is there a way to reference only one item from the array? 回答1: Well no, there is no way, but you could do something like this: <string name=

Android: Force close when trying to call Preferences.java

落花浮王杯 提交于 2019-12-11 18:46:54
问题 Been trying to call Preferences.java class using: Intent settingsActivity = new Intent(getBaseContext(), Preferences.class); startActivity(settingsActivity); I have this in my Manifest.xml (outside the main app class activity): <application> ........ <activity android:name=".Preferences" android:label="Preferences"> </activity> </application> And I still get force close for "android.content.ActivityNotFound..." : E/AndroidRuntime(25644): FATAL EXCEPTION: main E/AndroidRuntime(25644): android