我创建了一个带有图像列表的自定义gridView&每个都有一个删除图标。一旦按下删除图标,就应该删除相应的图像。路径位置的正确图像将被删除& imgList也按预期修改。但是在gridView中,网格的最后一个图像被删除(或者似乎是这样)。但是在按下后退按钮和前进按钮时,gridView会按预期显示正确的数据。
对于Ex:让ArrayList为{1,2,3,4,5}。按下删除'3'。然后ArrayList将是{1,2,4,5},图像'3'也将从其位置删除。但是gridView显示{1,2,3,4}而不是{1,2,4,5}。在背压和&正向按下,gridView将其正确显示为{1,2,4,5}。
在谷歌搜索中找不到除notifyDataSetChanged()之外的任何相关内容。有关如何解决此问题的任何建议?
代码:
root@6bd6c7262e96:/opt/batch/jobs# bq show -j bqjob_r2257fe91a590a308_0000014e3e922faf_1
Job infra-bedrock-861:bqjob_r2257fe91a590a308_0000014e3e922faf_1
Job Type State Start Time Duration Bytes Processed
---------- --------- ----------------- ---------- -----------------
load FAILURE 29 Jun 09:07:42 0:00:02
Errors encountered during job execution. System error. The error has been logged and we will investigate.
答案 0 :(得分:0)
你应该这样做:
string[] a = {"{0}", "hit", "{1}"};
string[] b = {"Player", "Enemy"};
var result = string.Format(string.Join(" ", a), b);
答案 1 :(得分:0)
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View grid = inflater.inflate(R.layout.grid_single, null);
if(convertView == null) {
View grid = inflater.inflate(R.layout.grid_single, null);
ImageView bin = (ImageView)grid.findViewById(R.id.grid_delete_image);
bin.setTag(position);
bin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
positon = v.getTag();
imgList.remove(imgList.get(position).toString());
File fs = new File(imgList.get(position).toString());
Boolean fileDeleted = fs.delete();
if(fileDeleted) {
Toast.makeText(mContext, "Image Deleted:" + Integer.toString
(position), Toast.LENGTH_SHORT).show();
notifyDataSetChanged();
}
}
});
} else {
grid = (View) convertView;
}
final String imgPath = imgList.get(position).toString();
Bitmap bitmap = BitmapFactory.decodeFile(imgPath);
if(bitmap != null) {
ImageView img = (ImageView)grid.findViewById(R.id.grid_image);
img.setImageBitmap(bitmap);
}
return grid;
}