android-preferences

Using listpreference and getting the key works but no ok button

微笑、不失礼 提交于 2019-12-22 04:03:45
问题 I'm using listpreference in my android app and getting my key values and all is well and works good (now that you guys have helped me) BUT - when my listpreference menus popup, they only contain a cancel button. Let's say the user is choosing between red, blue, and green. When the listpreference dialog first pops-up, the dialog only shows a cancel button. Because of that, the dialog disappears as soon as the user selects their choice. I would like it so that when the user chooses their

Applying custom theme to ActionBar in PreferenceFragment

家住魔仙堡 提交于 2019-12-21 19:53:45
问题 I am trying to apply custom theme to ActionBar in PreferenceFragment . Following is the scenerio: My class extends PreferenceFragment in which I am adding preferences from resouces as: addPreferenceFromResource (R.xml.myPrefs); Also, I have written: ActionBar a = getActivity ().getActionBar (); bar.setNavigationMode (ActionBar.NAVIGATION_MODE_TABS); Now I want to apply my own theme that I defined in styles.xml to this action bar. Currently, the height of action bar is smaller that the tab

Is there a way to add a seekbar to my actual preference screen?

◇◆丶佛笑我妖孽 提交于 2019-12-21 17:16:32
问题 I keep seeing the tutorial on adding your own seekbar preference, but its not in my actual prefs.xml. Is there any way to have one in my main prefs screen or will I have to separate it. 回答1: There seem to be 2 slider preferences by Google - SeekBarPreference - inline SeekBarDialogPreference - dialog based but I am not sure when they will be available. You could use a custom inline SeekBarPreference by me (see the 2 sliders at the bottom): My code is quite simple - SeekBarPreference.java:

Add ActionBar to a PreferenceActivity

China☆狼群 提交于 2019-12-21 09:24:29
问题 I am trying to make a Settings Activity using a PreferenceActivity . The problem is that the ActionBar won't show up no matter what I do. I've tried getSupportActionBar , getActionBar , setActionBar . Nothing works. I see other apps settings with ActionBar s. Do they not use PreferenceActivity ? 回答1: If you are using an AppCompat theme, you have to pay attention to some points. The PreferenceActivity doesn't extend the AppCompatActivity or the deprecated ActionBarActivity . As solution you

How to access widgets in a custom DialogPreference with a inflated layout?

南楼画角 提交于 2019-12-20 18:39:32
问题 Im very new to android and Im trying to load/persist values from my customized DialogPreference. Currently, this fails because findViewById returns null. Is the way I (try) to do it correct? How do I get access to my EditText widgets in the code? public class AddressDialogPreference extends DialogPreference { public AddressDialogPreference(Context context, AttributeSet attrs) { super(context, attrs); setDialogLayoutResource(R.layout.address_dialog); } @Override protected void onBindDialogView

After changing a preference (a setting), text showing settings doesn't update

倾然丶 夕夏残阳落幕 提交于 2019-12-20 18:31:26
问题 I will try to explain a simple app scenario: My app goes right to a 'main view'. In this main view I have inserted a TextView which displays current settings created by way of the PreferenceManager . For simplicity sake, let's say I have a checkbox in my settings. When I first start my app - the TextView on my main view shows my checkbox setting correctly (true). Now I go to the settings menu, it pops-up, and then I change it to false. I go back to the main view and see no change. It still

How can a PreferenceActivity use a custom preference file

空扰寡人 提交于 2019-12-20 11:28:12
问题 My first attempt at preferences was without knowledge of PreferenceActivity . So now I have an app that stores all user preferences in a specific preference file. I want to migrate to using a PreferenceActivity but I also want my users to keep their preferences. Is there a way to tell my PreferenceActivity to use that specific file for all preferences? 回答1: You could read all the preferences at the beginning of your app, and then store them in the Preferences using Editor e =

Button in preference file

♀尐吖头ヾ 提交于 2019-12-20 07:17:33
问题 I have set the two buttons in preference.xml file. I want to go to main activity when I click the "ok" button. So for that code is where to write? 回答1: You can set an onPreferenceClickListener in your PreferenceActivity. in preference xml : <Preference android:title="Preference Button" android:summary="This works almost like a button" android:key="mypref" /> in preferences activity : public class Preferences extends PreferenceActivity { @Override protected void onCreate(Bundle

startactivityforresult from dialogpreference (non activity)

好久不见. 提交于 2019-12-20 05:51:31
问题 I have a dialog preference with a button on it that I want to have open another activity. When that activity is complete, I want the dialog to update a textview (in the dialog) with the information that was gathered from the activity. In other words: Preference screen --> Dialog preference --> Dialog --> Button click event --> Activity I used to have a normal activity call the activity (Activity --> Button click --> Activity) so I could use startactivityforresult, and then call my syncgui

How to open a new PreferenceFragment from current one, using the new Android-X API?

微笑、不失礼 提交于 2019-12-19 20:43:21
问题 Background On previous versions of support library, we could use headers in order to have a main-menu screen of settings, that each would open a new settings screen (fragment) . The problem Now headers are gone (as written here) for some time, and I think it became worse on android-x : One thing you’ll note isn’t in here is preference headers and you’d be totally right. However, that doesn’t mean a single list of preferences need to span a 10” tablet screen. Instead, your Activity can