[英]Listview items Animation Stop While Scrolling
我正在嘗試使用每個ListView
項目的簡單動畫顯示ProgressBar
,但是當我滾動時, ProgressBar
動畫停止。 滾動結束后,動畫再次開始。 見下圖。
你必須在getView()中使用動畫並為convertView示例設置動畫:
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
StructureArticles item = getItem(position);
if (convertView == null) {
convertView = G.inflater.inflate(R.layout.adapter_articles, parent, false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.fill(this, item, position);
Animation animationListView = AnimationUtils.loadAnimation(context, R.anim.scale_fade_in);
convertView.startAnimation(animationListView);
return convertView;
}
我在我的適配器中使用了這個語法並且問題解決了!
public class AdapterDownload extends ArrayAdapter<StructDownload> {
public AdapterDownload(ArrayList<StructDownload> array) {
super(G.context, R.layout.item_layout, array);
}
private static class ViewHolder {
public ViewHolder(View view)
{
}
public void fill(final ArrayAdapter<StructDownload> adapter, final StructDownload item, final int position)
{
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
}
}
謝謝。
它正在停止,因為當列表項可見時,會一次又一次地調用getview,從而重置視圖以避免設備上的任何幀跳過/滯后。
你需要做的是創建一個帶有布爾值的視圖持有者並將其設置為視圖的標簽..每次都是動畫布爾應該是真和假,當它停止時..所以當調用getview時你的進度條動畫仍然是根據布爾值開始或停止..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.