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

}

相关推荐
赏金术士8 小时前
Kotlin ViewModel
android·kotlin
vistaup9 小时前
kotlin 二维码实现高斯模糊
android·kotlin
愈努力俞幸运10 小时前
function calling与mcp
android·数据库·redis
阿巴斯甜11 小时前
LeakCanary
android
阿巴斯甜11 小时前
compose
android
阿巴斯甜11 小时前
Glide
android
-SOLO-11 小时前
使用Perfetto debug trace查看超时slice
android
阿巴斯甜11 小时前
Retrofit
android
阿巴斯甜11 小时前
OkHttp
android
阿巴斯甜12 小时前
Flow
android