Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有一个静态 Imageview 的框架布局,其中随机放置了其他 Imageview。我想使用“getChildCount”来获取那些随机放置的ImageViews的数量,但它也指的是静态的。我该如何解决?
只有在布局上添加和绘制新的 ImageView 时,您才应该调用 getChildCount。尝试使用:
view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { view.getChildCount() } })