public View getView(final int pos, View arg1, ViewGroup arg2) {
ViewHolder holder;
View view = arg1;
if (arg1 == null) {
holder = new ViewHolder();
System.out.println("Inflating view");
arg1 = mInflater.inflate(R.layout.inflatefreedownlod, arg2, false);
holder.im = (ImageView) arg1.findViewById(R.id.imf1);
holder.tv1 = (TextView) arg1.findViewById(R.id.tvf1);
holder.tv2 = (TextView) arg1.findViewById(R.id.mini1);
holder.tv3 = (TextView) arg1.findViewById(R.id.m1);
arg1.setTag(holder);
} else {
holder = (ViewHolder) arg1.getTag();
}
holder.tv1.setText(NAME.get(pos).toString());
holder.tv2.setText(contentName.get(pos).toString());
holder.tv3.setText(minidescp.get(pos).toString());
URL url1;
try {
url1 = new URL(imurl.get(pos).toString());
bmp = BitmapFactory.decodeStream(url1.openConnection().getInputStream());
holder.im.setImageBitmap(bmp);
//bmp.recycle();
} catch (Exception e) {
e.printStackTrace();
}
arg1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
for (int i = 0; i < NAME.size(); i++)
if (pos == i) {
getFreeContent(Cid.get(pos).toString(), Vid.get(pos).toString(), contentName.get(pos).toString());
}
}
});
return arg1;
}
我看到显示 Inflating View 3 次的 logcat。当我在模拟器上测试它时,我在列表视图中显示了 3 个 LinearLayout。为什么我的观点每次都是空的?视图也每次都膨胀。我的代码有什么问题