简体   繁体   中英

ListView not refreshing

I use the ListView just doesn't refresh unless I leave the activity and come back to it

for(int k = 0; k < toDelete.size(); k++){
    Log.v("removed", files.get(toDelete.get(k)));
    Integer record = toDelete.get(k);
    files.remove(record);
}

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, files);
setListAdapter(adapter);
adapter.notifyDataSetChanged();
list.invalidate();

I can see that the correct item is being removed via the log but it still stays on the display until the activity is exited.

Solution: it wasn't working because I'd used Integer instead of int. int is a primitive type whereas Integer is an object

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM