preferencefragment

Android: Error inflating class PreferenceScreen

限于喜欢 提交于 2019-12-06 09:44:37
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_notification" android:title="@string/notification_title" android:defaultValue="false"> <

SwitchPreference Listener with Custom Layout

谁说胖子不能爱 提交于 2019-12-06 07:44:49
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 like: SwitchPreference uiTestModePref = (SwitchPreference) findPreference("uitestmode"); uiTestModePref

Android PreferenceFragment No view found for id for fragment

ぐ巨炮叔叔 提交于 2019-12-06 01:59:43
So I'm making an android application and I started dealing with preferences, when I simply use a PreferenceActivity, everything works perfectly, however, if I use it with a PreferenceFragment, it crashes right after I click the button that calls intents to SettingsActivity with an error: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{*app package*/*app package*.SettingsActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f08003d for fragment SettingsFragment{41cc1a98 #0 id=0x7f08003d} this is SettingsActivity: public class

Divider between category in PreferenceFragment

∥☆過路亽.° 提交于 2019-12-05 22:33:29
问题 I'm trying to achieve Settings app look, which means I'm looking for solution to add divider between categories. So I thought I found solution, but unfortunately it's not working for me. As was suggested I should add empty preference with layout: </PreferenceCategory> <Preference android:title="Test" android:summary="Summary"/> </PreferenceCategory> <Preference layout="@layout/divider_preference" /> <PreferenceCategory android:title="Category"/> Here is divider: <LinearLayout xmlns:android=

Unable to show Snackbar from PreferenceFragment

隐身守侯 提交于 2019-12-05 20:43:51
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_related_to_your_transections"/> <SwitchPreference android:title="@string/promotional_notification"

PreferenceFragmentCompat custom layout

北战南征 提交于 2019-12-04 09:14:12
问题 I need a custom layout for my PreferenceFragmentCompat. In the docs for PreferenceFragmentCompat it seems that you can possibly inflate and return a view in onCreateView(). However a NPE results:- Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setAdapter(android.support.v7.widget.RecyclerView$Adapter)' on a null object reference at android.support.v7.preference.PreferenceFragmentCompat.bindPreferences

PreferenceFragment no scroll in CollapsingToolbarLayout

廉价感情. 提交于 2019-12-04 05:07:37
I have a problem with PreferenceFragment and CollapsingToolbarLayout. I have a base layout: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mainLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".activities.base.BaseActivity"> <android.support.design.widget.AppBarLayout android:id="@+id/appbarLayout" android:layout_width="match_parent" android:layout_height="@dimen/nav_header

Divider between category in PreferenceFragment

*爱你&永不变心* 提交于 2019-12-04 03:27:40
I'm trying to achieve Settings app look, which means I'm looking for solution to add divider between categories. So I thought I found solution, but unfortunately it's not working for me. As was suggested I should add empty preference with layout: </PreferenceCategory> <Preference android:title="Test" android:summary="Summary"/> </PreferenceCategory> <Preference layout="@layout/divider_preference" /> <PreferenceCategory android:title="Category"/> Here is divider: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height=

Keep the actionbar displayed in when changing PreferenceScreen

落爺英雄遲暮 提交于 2019-12-03 11:16:56
问题 I'm trying to display a actionbar in my preference screen. In order to do so I added the following code in my SettingActivity public class PreferencesActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.preferences_activity); getFragmentManager().beginTransaction() .replace(R.id.container, new PreferencesFragment()).commit(); getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW

Toolbar is hidden in nested PreferenceScreen

蓝咒 提交于 2019-12-03 07:58:37
问题 I use PreferenceFragment in ActionBarActivity from support-v7 library. In the Activity I have Toolbar . Everything goes okay, until I open a nested PreferenceScreen . In the opened screen the Toolbar is hidden. Maybe somebody know a workaround for this issue? Preferences xml-file: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory android:title="Main category" > <EditTextPreference android:defaultValue=