我正在尝试继续添加其他文件以添加到我的列表视图中...我可以将一个文件添加到我的listView中,但是当我选择要上传的其他文件时,它会摆脱旧项目并用新文件...我想继续添加到我的列表中,而不会删除任何内容...我知道我需要更新当前的适配器,但我对此感到困惑。
这是我所拥有的:
//update List
final ArrayList<Uri>FileUpload = new ArrayList<Uri>();
final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1,FileUpload);
// adapter.add(uri.getPath());
lv=(ListView)findViewById(R.id.ListViewUpload);
//Upload to list button with selected file
Button uploadList = (Button) findViewById(R.id.UpdateList);
uploadList.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
lv=(ListView)findViewById(R.id.ListViewUpload);
lv.setAdapter(adapter);
adapter.add(uri.getPath());
((BaseAdapter) lv.getAdapter()).notifyDataSetChanged();
Toast.makeText(dropBox.this, "File Added", Toast.LENGTH_SHORT).show();
}
});
答案 0 :(得分:0)
修改代码,无需每次添加项目都设置适配器。试试这个:
"https://maps.googleapis.com/maps/api/staticmap?size=512x512&scale=2&markers=shadow:true|scale:2|icon:"+"http://18.130.121.134/assests/source_icon.jpg"
+"|"+startLat+","+startLng+"&markers=shadow:false|scale:2|icon:"
+"http://18.130.121.134/assests/desti_icon.png"
+"|"+endLat+","+endLng+"&path=color:0xff0000ff|weight:5"