我在frameLayout上添加了五個視圖。在Framelayout上重新排列視圖順序android
如何重新安排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?
什麼是錯誤? –