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

}

相关推荐
91刘仁德4 小时前
MYSQL 事务原理及使用
android·mysql·adb
一笑的小酒馆5 小时前
AndroidKMP之瀑布流实现
android
RainyJiang5 小时前
AI时代下,Android的边界正在消失
android·openai·ai编程
Android-Flutter6 小时前
android 内存抖动详解
android
方白羽8 小时前
为什么 Android 非要用 Intent 传值?
android·ios·harmonyos
方白羽10 小时前
Android17 重写 MessageQueue,解决 Handler 隐性卡顿
android·app
蜡台11 小时前
Kotlin 零基础完整版实战教程|从语法入门到Android工程实战
android·开发语言·kotlin
律宏阔11 小时前
Android 车载 USB 开发笔记:USB Host、USB 串口、USB-CAN、HID 与系统 API
android
律宏阔11 小时前
Android 车载串口开发笔记:UART、RS232、RS485、串口配置与数据通信
android
YF021112 小时前
遥控器APP端自动重连方案
android