preferencefragment

New Preference support library incorrect theme at runtime

你离开我真会死。 提交于 2019-12-17 20:38:01
问题 I'm trying to use the new Preference v14 Support library. To give the preferences a material style, I use the following style on my Activity: <style name="PreferenceTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> </style> That works fine. My problem is that when I add new Preferences at runtime, they get inflated using an old theme. Here's a screenshot of the result: As you can see, the first preference

How to create settings screen in android app?

廉价感情. 提交于 2019-12-13 09:22:24
问题 How do I create a settings screen? Should I use PreferenceActivity or PreferenceFragment ? Note- Documentation wasn't helpful What I've already tried: Using PreferenceActivity but couldn't implement a simple toolbar in it. Using PreferenceFragment but was too complex to understand. What I want is a simple implementation using PreferenceFragment 回答1: On Android 3.0 and later, you should use a PreferenceFragment that displays your app settings. Create a SettingsFragment: public static class

Is it possible to remove a fragment without replacing it by another fragment?

点点圈 提交于 2019-12-13 06:55:27
问题 I use an ActionBarActivity with NavigationDrawer and a ListView in the content frame of Drawer. <?xml version="1.0" encoding="utf-8"?> <FrameLayout android:id="@+id/content_frame" android:layout_width="fill_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/lyt_list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="horizontal" > <ListView android:id="@+id/list_notes"

Create an Actionbar OptionsMenu in an PreferenceFragment

北城余情 提交于 2019-12-13 01:29:21
问题 I run into a problem while I was settings up the Preferences for my App . I would like to have a Button in the ActionBar (e.g. Save) but my ActionBar is not showing anything. I put this Line in the onCreate Method: this.setHasOptionsMenu(true) ; And implemented the public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) public boolean onOptionsItemSelected(MenuItem item) methods as well. However, it does not show anything. 回答1: Be sure your button item in your action menu layout

Dynamically add EditTextPreference

南楼画角 提交于 2019-12-11 18:14:11
问题 Is it possible to dynamically add EditTextPreference to PreferenceCategory in PreferenceFragment? Or set the number of EditTextPreference and then create as many? I will be gratefull for any help 回答1: I am using a helper class to build EditTextPreferences, using that I can do: Context context = getActivity(); PreferenceCategory statusCat = (PreferenceCategory) findPreference(context .getString(R.string.status_category)); EditTextPreference editTextPref = EditTextPrefBuilder.getBuilder(context

Fragment doesn't show second time it's used

旧巷老猫 提交于 2019-12-11 06:17:54
问题 I have a single Activity architecture where I'm loading a PreferenceFragmentCompat inside another ViewGroup in the MainActivity . Custom navigation exists within the MainActivity so that you can load the ViewGroup with the fragment and navigate away from it all within the same MainActivity . The first time I navigate to the ViewGroup , the PreferenceFragmentCompat loads perfectly fine. However, when I navigate away from the ViewGroup containing the PreferenceFragmentCompat and then back again

Android: Error inflating class PreferenceScreen

喜夏-厌秋 提交于 2019-12-10 10:48:11
问题 Please help me out here, I'm hitting brick wall for the last two days and can't figure it out. I have a simple PreferenceFragment and would like to inflate it from an Activity. Here is the res/xml/preferences.xml: <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="preferences"> <PreferenceCategory android:title="@string/notification_basic" android:key="notification"> <CheckBoxPreference android:key="enable_notification" android:summary="@string/enable

Empty PreferenceActivity though a PreferenceFragment was added

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 11:17:11
问题 I'm stuck with a pretty simple issue: I'm trying to build a Preference screen in my app and I'd like to do it with the new, now-standard PreferenceFragment method. This is my prefs xml: <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="@string/prefs_interface_settings"> <SwitchPreference android:key="show_average" android:title="Show average length of work day" android:defaultValue="false" android:summary="Display the calculated

SwitchPreference Listener with Custom Layout

核能气质少年 提交于 2019-12-07 22:43:10
问题 I'm trying to use a SwitchPreference in my Settings page, but i can't get the listener to work. I am using a custom widget layout in order to style the switch, as I cannot find how to use themes to achieve this. In my settings.xml i have the following: <SwitchPreference android:key="uitestmode" android:summary="Enable to display test data in fragments" android:title="UI Test Mode" android:widgetLayout="@layout/widget_custom_switch_on_off" > </SwitchPreference> and my SettingsFragment looks

Unable to show Snackbar from PreferenceFragment

倾然丶 夕夏残阳落幕 提交于 2019-12-07 14:56:07
问题 I want to use Snackbar onSharedPreferenceChange() inside my PreferenceFragment hosted by a Activity. preference.xml <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="ll_main"> <PreferenceCategory android:title="@string/push_notification"> <SwitchPreference android:title="@string/transectional_notification" android:key="trans_not" android:defaultValue="true" android:summary="@string/get_notified_about_any_changes