0
我有一個自定義對象的數組列表。每個自定義對象都對應於我的應用程序中滾動視圖中的模式。如果我的數組列表中有5個「時間卡」對象,則會有5個垂直堆疊的模式。Android:在for循環中爲視圖列表設置動畫
最終的行爲,我想,就是如果我有5張卡片的垂直堆疊,我想動畫的第一張牌,完成後,開始第二次,完成後,執行第三等
這裏是我的方法:
public void inflatetimeCardContainer(){
timecardContainer.removeAllViews();
int tclistIndex = 0;
for(TimeCard tc : timeCardList){
timeCardFragment = (RelativeLayout)LayoutInflater.from(this).inflate(R.layout.timecard_fragment, timecardContainer, false);
textViewTitle = (TextView)timeCardFragment.findViewById(R.id.textViewTitle);
textViewHours = (TextView)timeCardFragment.findViewById(R.id.textViewHours);
textViewPay = (TextView)timeCardFragment.findViewById(R.id.textViewPay);
textViewNotes = (TextView)timeCardFragment.findViewById(R.id.textViewNotes);
buttonDelete = (Button)timeCardFragment.findViewById(R.id.buttonDelete);
buttonDelete.setOnClickListener(handleButtonDelete);
buttonDelete.setId(tclistIndex++);
textViewTitle.setText(tc.getTitle());
textViewHours.setText("Hours: " + String.valueOf(tc.getHours()));
textViewPay.setText("Pay after taxes: " + String.valueOf((tc.getHours()*tc.getPayRate())*0.77));
textViewNotes.setText(tc.getNotes());
timeCardFragment.setAlpha(0);
timecardContainer.addView(timeCardFragment);
timeCardFragment.animate().alpha(1.0f);
// SOME KIND OF PAUSE HERE UNTIL ANIMATION IS DONE
// One the animation is done, continue in my for loop
}
}