
Java
Javapublic static void disableAllChildViews(ViewGroup viewGroup) {int childCount = viewGroup.getchildCount();for (int i = 0; i < childCount; i++) {View view = viewGroup.getchildAt(i);view.setEnabled(false);if (view instanceof ViewGroup) {disableAllChildViews((ViewGroup) view);} else if (view instanceof ListView) {ListView listView = (ListView) view;listView.setScrollable(false);listView.setEmptyView(null);}}}以上代码会禁用所有子视图,并且对于ListView,还会将其设置为不可滚动并清除其空内容。Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号