我有一个 ListView,当我的音频暂停时,我绘制一个 LayerDrawable 来显示播放量的进度。问题是当我将这个 ListView 元素从屏幕上移开并取回时 - 我看不到任何图像。
这是适配器的一部分:
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
allView=convertView;
if (view == null) {
view = lInflater.inflate(R.layout.item, parent, false);
}
............
switch (whatToDo) {
//here's my normal state of the Image
case 0 :
((ImageView) view.findViewById(R.id.ivImage)).setImageResource(p.imagestatus);
break;
//here's my Paused state of the Image - what I need to stay on the screen
case 1:
Log.e ("MyLog","paused! imagestatus="+p.imagestatus);
//Drawing progress
LayerDrawable ld= (LayerDrawable) ctx.getResources().getDrawable(R.drawable.onpause);
ClipDrawable cd=(ClipDrawable) ld.findDrawableByLayerId(R.id.clip_pause);
p.imagestatus=-p.imagestatus;
cd.setLevel(4500+(30*p.imagestatus));
((ImageView) view.findViewById(R.id.ivImage)).setImageDrawable(ld);
break;
...
return view;
}
所以,如您所见,几乎是常用的 getView 方法。但是当这个图像离开屏幕时 - 它永远不会回来。我该如何解决?