- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 LinearLayout,上面有几个 View 。所以我想要实现的是复制这个 LinearLayout 并在某个时候使用它。但是,当我对原始 LinearLayout 执行更改(例如方法 removeAllViews()
)时,它也会在副本上完成。
示例:
Log.d("debug1","1 vc"+variableContent.getChildCount());
this.anticsModulsVisibles = variableContent; //copy of the linearLayout
Log.d("debug1","2 vc"+variableContent.getChildCount());
Log.d("debug1","2.1 amv"+anticsModulsVisibles.getChildCount());
variableContent.removeAllViews(); //i remove the content of the original
Log.d("debug1","3 vc"+variableContent.getChildCount());
Log.d("debug1","4 amv"+anticsModulsVisibles.getChildCount());
以及日志的输出:
1 vc2
2 vc2
2.1 amv2
3 vc0
4 amv0
如您所见,anticsModulsVisibles
或 amv
正在遵循原始版本的情况。
我可以避免这种情况吗?也许将其设置为“最终”?可能吗?
谢谢。
最佳答案
每当您看到一个对象的更改反射(reflect)在您认为的副本中时,100% 的问题是您没有副本,而是对原始对象的第二个引用。您需要深入研究 LinearLayout
以确定 .clone()
方法是否已完全实现,或者手动复制所有字段
关于java - 如果我将 LinearLayout 实例化为现有 LinearLayout 的副本,那么一旦我对原始 LinearLayout 执行了一次操作,它也会在副本上完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18317954/
出于好奇,我尝试了一些原型(prototype)制作,但似乎只允许在第一个位置使用子例程的原型(prototype) &。 当我写作时 sub test (&$$) { do_somethin
我需要开发一个类似于 Android Play 商店应用程序或类似 this app 的应用程序.我阅读了很多教程,发现几乎每个教程都有与 this one 类似的例子。 . 我已经开始使用我的应用程
考虑一个表示“事件之间的时间”的列: (5, 40, 3, 6, 0, 9, 0, 4, 5, 18, 2, 4, 3, 2) 我想将这些分组到 30 个桶中,但桶会重置。期望的结果: (0, 1,
我是一名优秀的程序员,十分优秀!