preferenceactivity

How to get PreferenceScreen line height?

送分小仙女□ 提交于 2019-12-11 10:05:52
问题 How to get PreferenceScreen line height depend from xml in Preference subclass? public class MyPref extends Preference{ @Override protected void onBindView(View view) { super.onBindView(view); // Here getTop() & getBottom() is 0:0 } } EDIT & ANSWER from: Android: how to get value of "listPreferredItemHeight" attribute in code? value is in float listPreferredItemHeight public class MyPref extends Preference { private float listPreferredItemHeight; @Override protected View onCreateView

Your implementation of PreferenceActivity is vulnerable to fragment injection

江枫思渺然 提交于 2019-12-11 04:58:52
问题 Here is my java class. public class MyPrefrences extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); } } in my project i used preferences.xml <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="@string/steps_settings_title"> <ListPreference android:key="sensitivity" android:title="@string/setting" android:summary="

How to create a Listener to Preferences changes in Preferences activity?

冷暖自知 提交于 2019-12-11 04:44:45
问题 I have Preferences activity in my app that has ListPreference so the user can choose language for the app. The app displays the new language just after the user close the Preferences activity. I want to create a listener to the ListPreference so the app will restart when the Listener is triggers (just after the user choose a language/choose item from the ListPreference). How can I do that? SettingsActivity: public class SettingsActivity extends AppCompatPreferenceActivity { /** * A preference

How to remove the title bar from PreferenceCategory in PreferenceActivity

拈花ヽ惹草 提交于 2019-12-11 04:17:12
问题 This is my preferences xml file: myPreferences.xml: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory> <EditTextPreference android:key="name" android:title="Name" android:inputType="text" android:defaultValue="" /> <EditTextPreference android:key="email" android:title="Email" android:inputType="textEmailAddress" android:defaultValue="" /> <EditTextPreference android:key="phone" android:title="Phone Number"

PreferenceActivity error: doesn't show selected option after close Activity

六眼飞鱼酱① 提交于 2019-12-11 03:57:23
问题 The value is saved well in SharedPreference when i push it , but it doesn't show when i open another time the PreferenceActivity. It runs if i don't put the android:entryValues , but i can't use it cause there is some difference using distinct languages in order to see what's the value of the prefference. ¿Any idea of what can i do? Thanks for reading. code: the PreferencesMenu activity : public class PreferencesMenu extends PreferenceActivity { @Override public void onCreate(Bundle

How to open AlertDialog from preference screen?

大憨熊 提交于 2019-12-11 02:52:20
问题 My activity is below import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceActivity; import android.preference.PreferenceScreen; public class locationserviceSettings

PreferenceActivity saving preferences when app is destroyed

不打扰是莪最后的温柔 提交于 2019-12-11 01:24:04
问题 I have a MainActivity and a PreferenceActivity that is called from that Activity. I also have a Service running that queries for those preferences. When I print those values. I get this: D/pref_scrobble(4083): true D/pref_show_notification(4083): true D/pref_scrobble_only_on_wifi(4083): false D/pref_scrobble_percentage(4083): 50 Then I open PreferenceActivity. This gets printed: D/pref_scrobble(4083): true D/pref_show_notification(4083): true D/pref_scrobble_only_on_wifi(4083): false D/pref

PreferenceActivity works properly on Android 2.1, but not 4.1 (padded)

独自空忆成欢 提交于 2019-12-10 15:11:45
问题 I'm writing an application. It needs to run on old android OS's to be useful. I have written the preferences screen using a PreferencesActivity that populates with a options.xml file that contains PreferenceScreen. It has no submenu for preferences (so PreferenceFragment provides no real benefits). In Android 2.1 (2.2 and 2.3, haven't tested on ICS yet) the screen displays properly like so in landscape: But on Jellybean, it looks like this: It looks terrible. I have nothing defined as a

Cannot find TextView in PreferenceActivity

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 11:02:05
问题 In my PreferenceActivity I have some Preferences. One I inflate from layout: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.layout.settings); ... } protected void onResume() { super.onResume(); Preference registrationStatus = (Preference) findPreference("registrationStatusPref"); if (!TextUtils.isEmpty(somestring){ registrationStatus.setLayoutResource(R.layout.push_reg_status); TextView push_reg_status_txt = (TextView

Start/Stop service by checking/unchecking CheckBoxPreference

自闭症网瘾萝莉.ら 提交于 2019-12-10 10:26:23
问题 i'm writting an app that start or stop service by checking or unchecking CheckBoxPreference i tried to find some information such as sample code or tutorials. but i didn'f find yet. how to start or stop service by checking or unchecking CheckBoxPreference which is in PreferenceActivity ? i want to start service when "service_toggle" key is true and stop service when "service_toggle" key is false Are there any sample code or tutorial about Start/Stop service by checking/unchecking