Android initialExpandedChildrenCount高级菜单折叠项或铺展折叠项

/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/system_dashboard_fragment.xml

<PreferenceScreen

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:settings="http://schemas.android.com/apk/res-auto"

android:key="system_dashboard_screen"

android:title="@string/header_category_system"

settings:initialExpandedChildrenCount="4">

意思是,超过4个菜单则折叠隐藏起来,否则没超过直接平铺展开显示!

@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

final PreferenceScreen screen = getPreferenceScreen();
// We do not want to display an advanced button if only one setting is hidden
if (getVisiblePreferenceCount(screen) == screen.getInitialExpandedChildrenCount() + 1) {
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
}

}

相关推荐
plainGeekDev9 小时前
工厂模式 → Hilt
android·java·kotlin
雨白9 小时前
深入理解 Kotlin 协程 (十):引而不发,探秘 Flow 冷流机制与异常透明性
android·kotlin
plainGeekDev10 小时前
Application 单例 → Hilt Singleton
android·java·kotlin
程序员码歌11 小时前
我全程用 AI开发了一款微信小游戏,上线了
android·前端·游戏开发
黄林晴12 小时前
你敢信吗?同样是跨端,KMP 跟 RN 居然差这么多!
android·前端
zbmwa13 小时前
jetpack compose 副作用 produceState
android
hunterandroid14 小时前
Android 后台任务可靠性排查:从 WorkManager 观测到失败重试闭环
android·前端
GitLqr16 小时前
Flutter FocusNode 实战指南:玩转键盘焦点与用户输入体验
android·flutter·ios
zzq779716 小时前
Android 17 升级后 System.load 报错排查与加固兼容指南
android·安全·app加固·apk加固·御盾安全·免费加固·御盾加固
酷在前行17 小时前
【R绘图】Nature Communications 半眼图复刻:分布、区间与多面板排版(保姆级教程)
android·开发语言·r语言