【发布时间】:2012-12-11 22:42:27
【问题描述】:
我在 frameLayout 上添加了五个视图。
如何重新排列framelayout的childIndex。
我使用以下代码:
fromindex = 3;
toindex = 4;
View tempFrom = frameLayout.getChildAt(fromindex);
View tempTo = frameLayout.getChildAt(toindex);
frameLayout.removeViewAt(fromindex)
frameLayout.removeViewAt(toindex)
frameLayout.addView(tempFrom, toindex)
frameLayout.addView(tempTo,fromindex)
但它会引发以下错误。
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
framelayout的childindex如何重新排列?
【问题讨论】:
标签: android