我做的GridView中每个图片中都有一个按键,默认是显示的.当网上下载缓存到本地时.如果缓存没有清除的话按键就一直隐藏.
现在的问题是当我退出时,已经隐藏好的按键,又显示出来了.只有在点击时才会隐藏,我如何做才能把缓存好图片的按键一直隐藏,
这是我在Adapter中写的代码.请看看有什么要改的地方
class MyAdapter extends BaseAdapter {
int clickTemp = -1;
public void setSeclection(int position) {
clickTemp = position;
}
@Override
public int getCount() {
return urlList.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null){
view=View.inflate(ReplaceBackgroundActivity.this, R.layout.background_item, null);
convertView=view;
}
ImageView iv_background = (ImageView) convertView.findViewById(R.id.iv_background);
background_dot=(ImageView) convertView.findViewById(R.id.background_dot);
File dir2=new File(Environment.getExternalStorageDirectory()+IMAGE_CACHE_PATH);
if(dir2.exists()){
background_dot.setVisibility(View.GONE);
}else{
}
if (position == 0) {
iv_background.setScaleType(ScaleType.FIT_CENTER);
iv_background.setPadding(100, 25, 100, 30);
iv_background.setImageBitmap(bitmapList.get(0));
background_dot.setVisibility(View.GONE);
// iv_background.setPadding(left, top, right, bottom);
}else if(position==1){
iv_background.setImageBitmap(bitmapList.get(position));
iv_background.setScaleType(ScaleType.FIT_XY);
iv_background.setPadding(1, 1, 1, 1);
background_dot.setVisibility(View.GONE);
}
else {
String url = urlList.get(position);
if(url.indexOf("http")!=-1){
mImageLoader.displayImage(url,iv_background,options);
iv_background.setScaleType(ScaleType.FIT_XY);
iv_background.setPadding(1, 1, 1, 1);
}else{
Bitmap bm = BitmapFactory.decodeFile(url);
iv_background.setImageBitmap(bm);
iv_background.setScaleType(ScaleType.FIT_XY);
iv_background.setPadding(1, 1, 1, 1);
background_dot.setVisibility(View.GONE);
}
}
if (clickTemp == position) {
convertView.setBackgroundResource(R.drawable.gridview_shape);
background_dot.setVisibility(View.GONE);
} else {
convertView.setBackgroundResource(R.drawable.gridview_shape2);
}
return convertView;
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。