ListView 中闪烁的行过多
Too much blinking rows in ListView
我 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' 的行。这些行确实在闪烁,但在我的列表中,第一行在闪烁,每个下一个 "screen" - ListView
的第一行都有 11 行可见,闪烁的是第 1、13、25、37 行.. .
重要的是着色日期(切换指令)工作正常。我只有 Animation
.
有问题
我做错了什么?
当您回收视图时,动画可能会继续。尝试使用 View.clearAnimation().
清除任何当前动画
if (date_status.get(position).equals("zgłoszone")) {
...
} else {
convertView.clearAnimation();
}
我 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' 的行。这些行确实在闪烁,但在我的列表中,第一行在闪烁,每个下一个 "screen" - ListView
的第一行都有 11 行可见,闪烁的是第 1、13、25、37 行.. .
重要的是着色日期(切换指令)工作正常。我只有 Animation
.
我做错了什么?
当您回收视图时,动画可能会继续。尝试使用 View.clearAnimation().
清除任何当前动画if (date_status.get(position).equals("zgłoszone")) {
...
} else {
convertView.clearAnimation();
}