我有一个按钮,当我单击它时,我想删除 arraylist 第一个索引的值,是的,数组列表中的第一个索引被删除。但是我的列表视图中来自我的arraylist 的数据没有被删除。
我到这里为止
public ArrayList<String> imagesFileName = new ArrayList<String>();
mylist = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < imagesFileName.size(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put(FILE_NAME, filename[i]);
map.put(DESCRIPTION, "desc");
map.put(UPLOADEDBY, "uploadby");
map.put(DATE_UPLOAD, "date_upload");
map.put(ACTION, "delete");
map.put(ID, String.valueOf(i));
mylist.add(map);
}
adapter = new CustomArrayAdapter(getApplicationContext(), mylist, R.layout.attribute_ireport_list,
new String[]{FILE_NAME, DESCRIPTION, UPLOADEDBY, DATE_UPLOAD, ACTION, ID},
new int[]{R.id.tv_File, R.id.txt_Desc, R.id.tv_UploadedBy, R.id.tv_DateUploaded, R.id.tv_Action, R.id.txt_id}, true);
lv_iReport.setAdapter(adapter);
//code for delete of first index
btn_Upload = (Button) findViewById(R.id.button1);
btn_Upload.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
imagesFileName.remove(0);
adapter = new CustomArrayAdapter(getApplicationContext(), mylist, R.layout.attribute_ireport_list,
new String[]{FILE_NAME, DESCRIPTION, UPLOADEDBY, DATE_UPLOAD, ACTION, ID},
new int[]{R.id.tv_File, R.id.txt_Desc, R.id.tv_UploadedBy, R.id.tv_DateUploaded, R.id.tv_Action, R.id.txt_id}, true);
lv_iReport.setAdapter(adapter);
Toast.makeText(getApplicationContext(), "Deleted", Toast.LENGTH_LONG).show();
}
});