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

}

相关推荐
Kapaseker23 分钟前
破坏性更新 - 解读 Jetpack Compose 1.12
android·kotlin
雨白1 小时前
我的 UML 学习笔记:结合 Android 实例看懂 4 种常用图表
android·架构
怣疯knight1 小时前
快速判断apk有没有支持16kb页面标准
android
风流 少年2 小时前
Spring AI 2.0:Advisor
android·人工智能·spring
YM52e4 小时前
分页查询的基石:ArkTS 为鸿蒙商品列表设计 LIMIT/OFFSET 的表
android·学习·华为·harmonyos
安卓与AI研习社5 小时前
Android ANR 到底怎么定位?从触发原理到日志判断的完整方法
android
阿pin7 小时前
Android随笔-MVI
android·mvi
leobertlan7 小时前
【好玩系列】训练一个神经网络指导小孩玩游戏
android·机器学习·程序员
Android-Flutter8 小时前
android LeakCanary 工作原理 详解
android·kotlin
newcih8 小时前
从原理到实战:LSPosed 模块开发完全指南(2026 修订版)
android·xposed·lsposed