我在程序中继承BaseAdapter为ListView添加了多个ImageView,这个ImageView是根据数据动态生成的波形图,现在只有ListView中的第一个ImageView可以正常的显示出波形图,而其它的都没有,但是我通过打的Log看到,其它的ImageView也调用了onDraw函数,而且数据都是对的,可就是没有画出来,请各位帮助分析一下,下面贴上代码:TestListActivity继承了ListActivity,里面有一个内部类继承自BaseAdapter,MyImageView继承自ImageView,根据传递过来的数据画出波形图,QueueItem就是存放这些数据的,如波形图在屏幕中的位置,y轴各点的位置,x轴是每4个像素一个点。public class TestListActivity extends ListActivity { private ArrayList<QueueItem> list;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle b = getIntent().getExtras();
list = (ArrayList<QueueItem>) b.getSerializable("list");
MyAdapter adapter = new MyAdapter(this);
setListAdapter(adapter);
}
public final class ViewHolder{
//public TextView title;
public MyImageView img;
}

public class MyAdapter extends BaseAdapter{ private LayoutInflater mInflater;
private Context mContext;
public MyAdapter(Context context){
this.mInflater = LayoutInflater.from(context);
mContext = context;
}
public int getCount() {
return list.size();
}
public Object getItem(int position) {
if(position>list.size())
return null;
else
return list.get(position);
}
public long getItemId(int position) {
return position;
} public View getView(int position, View convertView, ViewGroup parent) {

ViewHolder holder = null;
if (convertView == null) {
holder=new ViewHolder();  
convertView = mInflater.inflate(R.layout.image_view, null);
holder.img = (MyImageView)convertView.findViewById(R.id.image);
convertView.setTag(holder);

}else {
holder = (ViewHolder)convertView.getTag();
} holder.img.setImageResource(R.drawable.backgroud);
holder.img.setQueueItem(list.get(position));
//holder.img.postInvalidate();
convertView.setTag(holder);
return convertView;
}

}
}MyImageView:public class MyImageView extends ImageView {
private Paint paint ;
private QueueItem queue;
private int floor=0;
private int ceil=0;
private int height = 0;
private int width = 0;
    private Path path;
    private float scale=0;
    
   public MyImageView(Context context, AttributeSet attrs) {  
    
        super(context,attrs);   
    }  
   public void setQueueItem(QueueItem queue){
this.queue = queue;
floor = queue.getFloor();
ceil = queue.getCeil();
DisplayMetrics dm=new DisplayMetrics();
dm = this.getContext().getApplicationContext().getResources().getDisplayMetrics();
width=dm.widthPixels;
height=dm.heightPixels;
scale = (float)(ceil-floor)/height;
Log.d("floor+ceil", Integer.toString(floor)+"+"+Integer.toString(ceil));
Log.d("width+height", Integer.toString(width)+"+"+Integer.toString(height));

initContextView();
//buildPath();
//postInvalidate();
   }
private void initContextView(){
setBackgroundColor(Color.WHITE);
path = new Path();
paint = new Paint();
paint.setColor(Color.rgb(24, 142, 198));
paint.setStrokeWidth(2);
paint.setStyle(Style.FILL);
}
private void buildPath(){
path.moveTo(0, ceil);
     Iterator<Integer> iterator = queue.getX().iterator();
     int i = 4;//x轴
     int y=0;
     while(iterator.hasNext()){ 
     Integer temp = iterator.next();
     y = (int)(temp*scale);
     y = ceil-y;
     path.lineTo(i, y);
     //Log.d("i="+i, Integer.toString(y));
     i+=4;
     }
     //Log.d("i="+i, Integer.toString(y));
path.lineTo(i, ceil);
} @Override
protected void onDraw(Canvas canvas) { buildPath();
Log.d("onDraw", Integer.toString(this.floor));
canvas.drawPath(path, paint);
}}QueueItem:
public class QueueItem implements Serializable{ //private int id;
private int ceil;
private int floor;
private int height;
private int xCount;
private Queue<Integer> x;
public QueueItem(){
this.xCount = 120;
this.height = 200;
this.x = new LinkedList<Integer>(); }
public QueueItem(int xCount){
this.xCount = xCount;
this.x = new LinkedList<Integer>();
this.height = 200; } public QueueItem(int xCount,int height){
this.xCount = xCount;
this.x = new LinkedList<Integer>();
this.height = height; }
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getxCount() {
return xCount;
}
public void setxCount(int xCount) {
this.xCount = xCount;
}
public int getCeil() {
return ceil;
}
public void setCeil(int ceil) {
this.ceil = ceil;
}
public int getFloor() {
return floor;
}
public void setFloor(int floor) {
this.floor = floor;
}
public Queue<Integer> getX() {
return x;
}
public void setX(Queue<Integer> x) {
this.x = x;
}
/* public Queue<Integer> getX() {
return x;
}*/
public void pushX(int xx) {
if(x.size()<=xCount){
if(x.size()==xCount)
x.poll();
x.offer(xx);
}
}