[英]Why, in androidx settings/preferences, am I getting "java.lang.String cannot be cast to java.lang.Integer" exception?
在我的 preferences.xml 我有這個: 使用這些 arrays: 在我的 onSharedPreferenceChanged 中: 每當此 onSharedPreferenceChanged 代碼運行時,它都會收到此異常: 為什么? ...
[英]Why, in androidx settings/preferences, am I getting "java.lang.String cannot be cast to java.lang.Integer" exception?
在我的 preferences.xml 我有這個: 使用這些 arrays: 在我的 onSharedPreferenceChanged 中: 每當此 onSharedPreferenceChanged 代碼運行時,它都會收到此異常: 為什么? ...
[英]Implementation of getString() of PreferenceDataStore method
我正在使用繼承 PreferenceDataStore 的自定義 DataStore 來存儲我的 android 應用程序中設置活動的首選項。 我想實現 getString() 方法,因為 PreferenceDataStore.getString() 方法不執行任何操作。 -> Prefe ...
[英]MultiSelectListPreference keeps old values. Is it a bug and what can be done?
如果更改了 MultiSelectListPreference 的選擇數組,則用戶無法刪除先前存儲在首選項中的選擇。 我在 xml 中寫了一個 MultiSelectListPreference 如下,並在 PreferenceFragmentCompat 中使用它: 數組是 在 UI 中選擇所有 ...
[英]kotlin, why coroutines launch block only runs one function in it when a DataStore is used in the function,
launch協程以執行三個功能。 如果 function 正在執行除訪問 DataStore 之外的其他操作,則所有三個功能都按預期完成。 但是如果 function 正在訪問 DataStore, 然后只調用第一個 function。 但是如果將三個函數放在它們自己的launch塊中,那么這三 ...
[英]How to use material 3 Switch in PreferenceFragmentCompat programmatically?
SwitchPreferenceCompat 仍然保留舊的 Switch 樣式,我知道可以通過以下方式為其設置 Material 3 樣式: 主題.xml<style name="Theme.Material3.Preference" parent="Theme.Material3.Day ...
[英]Problems with create custom PreferenceScreen and mange each one in SettingsFragment - kotlin
根據這個問題,我正在嘗試創建一個自定義布局並將其添加到我的根 PreferenceScreen XML,但我遇到了一些問題,首先,當我將switch_preference_layout.xml添加到 Preference 標記中時,它看起來已損壞這是我切換到暗模式示例的自定義布局 它看起來像下面 在 ...
[英]New Android 12+ MaterialSwitch and androidx.preference
所以我正在更新我的應用程序以完全支持 Monet 和 Material You 指南,官方網站提到了開關的新設計。 我使用了它,結果如下: 我有一個使用 Androidx 首選項庫的首選項屏幕,在撰寫本文時可用的最新版本,我發現為開關設置主題的唯一方法(除了手動主題,這沒有意義)是在應用程序的主 ...
[英]Hide a Preference-item depending on the state (enabled/disabled) of another Preference in PreferenceScreen
我正在創建一個設置屏幕,我有一些設置項: SwitchPreferenceCompat和我的CustomPreference 。 我需要СustomPreference 在 SwitchPreferenceCompat 關閉時消失(隱藏)並在SwitchPreferenceCompat 打開時出現 ...
[英]PreferenceManager(context) is private in the pacakage
PreferenceManager(context)在 package 中是私有的,我需要將其轉換為public使用。 我不知道該怎么做。 那么,任何人都可以幫助我嗎? ...
[英]'PreferenceManager()' is not public in 'android.preference.PreferenceManager'
這一行給了我錯誤: - preferenceManagers = new PreferenceManager(getApplicationContext()); 我得到這個錯誤: - 'PreferenceManager()' 在 'android.preference.PreferenceMa ...
[英]how to display preference values
由於警告,我正在嘗試遷移我的應用程序的首選項部分 但是,即使在閱讀了大量資源之后,我也不明白為什么我不能像以前那樣在 EditTextPreference 前面(或下面)顯示 2 個首選項值(字符串和整數)。 “Compte”(在捕獲中)(字符串)已啟用 =“false”,因為我不希望用戶可以編輯 ...
[英]Implement a split preference in Android
我覺得必須有一種直接的方法來實現這一點,但到目前為止我還沒有找到。 從本質上講,在股票設置應用程序中,有一些偏好是“分開的”——也就是說,點擊偏好的文本做一件事,而點擊右邊的圖標做另一件事。 我嘗試制作一個擴展PreferenceGroup的自定義首選項,但似乎PreferenceGroup並沒有 ...
[英]Referencing an Android Preference Tag's layout
我一直在嘗試在 Preference 標記內使用的 XML 文件中引用 TextView。 以下是我的文件結構的簡化版本: 主要的.xml custom_layout.xml primary_fragment.kt 我也沒有任何問題引用特定的 Preference 標記以在 pri ...
[英]How to get all keys of Android Preferences DataStore
如標題所述,有沒有辦法獲取存儲在 Android Jetpack Preferences DataStore中的所有密鑰,例如dataStore ...
[英]Android Preferences DataStore Flow Doesn't Emit Same Value
只是測試Preferences DataStore並發現提供的Flow輸出不會發出相同的值,我的設置如下: 數據存儲實用程序類: 視圖模型類: 片段類: 由於我每次都保存true ,並且Log只顯示一次,這意味着Flow不會發出相同的值。 我對么? 這是故意行為嗎? ...
[英]MapFragment becomes slow after navigating back to it from a preferencesFragment
我向應用程序添加了首選項片段。 我正在使用 ActionBar 下拉菜單導航到首選項片段,並使用 ActionBar 的 OnUpNavigation 按鈕返回到先前顯示的片段,該片段使用 OnBackPressed 方法返回 go。 該應用程序還有一個由 NavController 控制的 Bot ...
[英]Android change Dialog background color from app settings via styles
我想更改我的 PreferenceActivity 的默認對話框背景顏色(在我們從設置列表中選擇選項的位置打開的對話框)。 現在 Dialog 的背景總是白色的,盡管我在 styles 中更改了它。我正在嘗試像在我的代碼中那樣解決這個問題,但它不起作用。 這是我的明暗 styles。 styles ...
[英]Not able to find "extra" attribute in jetpack preference in Android
我正在嘗試構建設置類型的應用程序,我選擇使用首選項來構建 UI。 我正在使用噴氣背包首選項 (androidx.preference.Preference),如果我想啟動帶有一些額外功能的片段,可以使用下面的正常首選項。 但在 Jetpack 首選項中,沒有“額外”屬性。 從偏好視圖發送額外的任何替 ...
[英]How to create a dual action (normal + switch) preference in Android?
有什么辦法可以實現這個雙作用偏好項嗎? 最好通過第三方庫,但必要時通過簡單的實現。 Android 開發人員模式中的“無線調試”偏好是雙重偏好。 這是我見過的唯一一個,我不知道這個首選項叫什么,也不知道 Jetpack 或其他庫是否公開了這樣的東西。 點擊左側部分 (1) 打開一個新屏幕,而點擊 ...
[英]can I add custom attributes to components in preferences.xml without making custom views?
我正在嘗試將 state 或具有某種自定義屬性的數據存儲到首選項中的現有組件中。xml 稍后我可以在代碼中引用和讀取。 如果可能的話,我想避免為所有這些組件創建自定義視圖,因為這意味着每次有人想向新組件添加屬性時,我都必須創建一個新的自定義視圖。 例如,我想將mycustomatt:forced= ...