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

}

相关推荐
大圣编蚕3 小时前
初探 NDK 的世界:从零开始理解 Android 原生开发
android
云贝贝贝3 小时前
MySQL 慢查询定位与索引优化实战
android
骑着蜗牛撵大象3274 小时前
服务下线不再炸:分层关闭、TCP 存活探测与负载均衡排水的落地套路
android·tcp/ip·负载均衡·tcp·高可用·健康检查·优雅关闭
三少爷的鞋6 小时前
别再这么写协程了!Marcin Moskała 剖析的 几个常见协程误区与重构
android
mmsx7 小时前
Android 防二次打包第一道锁:签名校验与完整性校验
android·kotlin
mmsx7 小时前
Android 混淆不等于安全:二次打包链路完整走一遍
android·kotlin
小宋10219 小时前
Agent轨迹级评测实战:工具选择、预算超限与回归门禁
android·网络·人工智能·回归
墨天梦11 小时前
D05_ViewModel与单向数据流
android·kotlin
蒸鱼Yuzheng12 小时前
Android 构建可复现性:APK 指纹、文件级差异与供应链审计
android·apk·devops·软件供应链·可复现构建
墨天梦15 小时前
D03_Compose列表与稳定身份
android·gitee·kotlin