icon android 图片资源列表 url,android-在现有ListVIew中添加更多项目时,Image...

我正在创建一个ListView作为一个TextView和ImageView作为一个列表项行.

最初,我正在从本地数据库的列表视图视图中加载默认项,并且我在列表视图的顶部具有一个更新按钮,以便从服务器中加载更多项

当用户按下更新按钮时,我启动了AsyncTask,它从服务器中拉出图标网址和文本.

在ImageView中加载图标我正在使用ImageDownloader的示例,但问题是我的ImageView与ViewHolder模式的旧ImageViews bcoz重叠了.有人可以嘲笑我我在做什么错吗?

这是我的ListView适配器代码

@Override

public View getView(int position, View convertView, ViewGroup parent) {

ViewHolder holder;

TemplateData data = (TemplateData) this.getItem( position );

if(convertView == null){

LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

convertView=inflater.inflate(R.layout.text_template_default_row, parent, false);

holder = new ViewHolder();

holder.templateText = (TextView) convertView.findViewById(R.id.defText);

holder.templateIcon = (ImageView)convertView.findViewById(R.id.defIcon);

holder.templateTitle = (TextView) convertView.findViewById(R.id.defTitle);

convertView.setTag(holder);

}else{

holder = (ViewHolder)convertView.getTag();

}

holder.templateText.setText(data.getText() );

holder.templateTitle.setText(data.getTemplateTitle());

//isImageLoading initially sets to false so that default items will use the

// resource ids , it gets falsed when AsyncTask finished load Images and update the

//adapter and at that time this adapter has to pic the image from ImageDowloader

if(!isImageLoading)

data.setTemplateIconId(iconList[position]);

//Has resource id but not icon url

if(data.getTemplateIconId()!=0 && data.getTemplateIconUrl()==null ){

Log.d("Load icon ","Default Load");

holder.templateIcon.setBackgroundResource(data.getTemplateIconId());

// does not has recource id so load url from server

}else if(data.getTemplateIconUrl()!=null && data.getTemplateIconId()==0){

Log.d("Load icon ","From Server Load");

imageDownloader.download(data.getTemplateIconUrl(), (ImageView) holder.templateIcon);

}

return convertView;

}

iconList包含应用程序中现有图标的资源ID.

请随时询问是否有人需要更多信息.

编辑

这是屏幕截图

最初将有8个模板和其图标仅从存储在Android手机中的数据库加载.其名称从模板1到模板6

现在,当用户按下更新按钮时,新模板将在此处加载.它的名称从模板new 1开始到模板new 9,但是当我向上滚动n向下时,imageViews重叠了

这是屏幕截图

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值