ListView中的行闪烁太多

时间:2015-01-22 22:12:00

标签: java android listview adapter

我有listView有自己的适配器。这是适配器代码中的片段getView方法:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    //this code works properly            
    switch(dane_status.get(position)) {
        case "zgłoszone": mojView_holder.tekst_data.setTextColor(convertView.getContext().getResources().getColor(R.color.zamZgloszColor)); break;
         default: mojView_holder.tekst_data.setTextColor(0xFFC0C0C0); //silver
    }
    //this code not working properly
    if (dane_status.get(position).equals("zgłoszone")) {
        Animation anim = new AlphaAnimation(0.2f, 1.0f);
        anim.setDuration(200); //You can manage the blinking time with this parameter
        anim.setStartOffset(20);
        anim.setRepeatMode(Animation.REVERSE);
        anim.setRepeatCount(Animation.INFINITE);
        convertView.startAnimation(anim);
    }
    return convertView;
}

我正在使用Animation仅闪烁状态为'zgłoszone'的行。这些行确实在闪烁,但在我的列表中第一行闪烁,每个下一个“屏幕”上的每一行 - ListView有11行可见,闪烁是第1,13,25,37行...... / p>

着色日期(切换指令)正常工作很重要。我只遇到Animation的问题。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

回收视图时,动画可能会继续。尝试使用View.clearAnimation()清除所有当前动画。

if (date_status.get(position).equals("zgłoszone")) {
    ...
} else {
    convertView.clearAnimation();
}
相关问题