Android怎么禁用触碰事件?

Android

1个回答

写回答

q哈哈哈

2025-10-24 05:05

+ 关注

Java
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,还会将其设置为不可滚动并清除其空内容。

举报有用(0分享收藏

Copyright © 2025 IZhiDa.com All Rights Reserved.

知答 版权所有 粤ICP备2023042255号