2013-05-07 25 views
0

我正在學習StackView和AdapterViewAnimator。 並發現,在AdapterViewAnimator中,它不會直接刪除子項,而是將它們放入數組中, 並在下一階段刪除。爲什麼AdapterViewAnimator在兩個階段中刪除兒童?

有人能解釋一下這個設計的原因是什麼? 爲什麼我不能直接刪除它們?

的更多信息: 我也注意到, 由於上述設計, StackView(延伸AdapterViewAnimator) 都會有一些孩子流連忘返...... 並導致我想問問爲什麼。

的更多信息:下面 是代碼片段,我上面提到: (從AdapterViewAnimator.showOnly(INT,布爾值))

// This section clears out any items that are in our active views list 
    // but are outside the effective bounds of our window (this is becomes an issue 
    // at the extremities of the list, eg. where newWindowStartUnbounded < 0 or 
    // newWindowEndUnbounded > adapterCount - 1 
    for (Integer index : mViewsMap.keySet()) { 
     boolean remove = false; 
     if (!wrap && (index < rangeStart || index > rangeEnd)) { 
      remove = true; 
     } else if (wrap && (index > rangeEnd && index < rangeStart)) { 
      remove = true; 
     } 

     if (remove) { 
      View previousView = mViewsMap.get(index).view; 
      int oldRelativeIndex = mViewsMap.get(index).relativeIndex; 

      mPreviousViews.add(index); 
      transformViewForTransition(oldRelativeIndex, -1, previousView, animate); 
     } 
    } 

感謝。 BR, Henry

回答

0

在這種情況下, 它需要首先完成(輸出)動畫。

一旦動畫完成, 它可以被真正刪除。

因此,它不會立即刪除這些視圖。

PS。如果我錯了,請糾正我。