能否從onItemSelected()中獲取views數組?因為我需要給當前的視圖設置動畫,並且清除其它視圖的動畫,能這樣做嗎?
@Override
public void onItemSelected(AdapterView<?> adV, View view, int currentIndex, long l)
{
view.startAnimation(AnimationUtils.loadAnimation(currentContext, R.anim.scale_anim));
adV[currentIndex + 1].clearAnimation();
adV[currentIndex - 1].clearAnimation();
}
你應該遍歷 AdapterView 的子類
int count = adV.getChildCount();
for (int i = 0; i < count; i++) {
View v = adV.getChildAt(i);
view.clearAnimation();
}
當然你要檢查 view 是否是當前的。