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);
}

}

相关推荐
plainGeekDev7 小时前
Android性能优化面试题:你说你会优化,结果连ANR都排查不了
android·面试
richard_yuu7 小时前
鸿蒙本地数据存储实战|Preferences 封装、数据隔离与隐私合规存储方案
android·华为·harmonyos
木易 士心7 小时前
深入理解 OKHttp:设计模式、核心机制与架构优势
android·设计模式·架构
Ehtan_Zheng8 小时前
Jetpack Compose `@ReadOnlyComposable` 的“魔法”
android
沐言人生8 小时前
ReactNative 源码分析11——Native View创建流程setChildren和manageChildren
android·react native
诸神黄昏EX8 小时前
Android Build系列专题【篇七:VINTF源码解析】
android
plainGeekDev8 小时前
Android Framework 面试题:Binder都说不清楚,简历别写精通了
android·java
萌新杰少8 小时前
安卓原生项目迁移KMP——核心迁移
android·kotlin·jetbrains
小孔龙8 小时前
AndroidManifest.xml 配置速查手册
android
七牛云行业应用8 小时前
OpenAI Codex手机版上线实战:iOS/Android 5步配置远程控制指南(2026)
android·ios·智能手机