我在 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 ?