我創建適配器ListView和陣列適配器和除去
public class MyArrayAdapter extends ArrayAdapter<Watch>
重寫
public MyArrayAdapter(Context context, List<Watch> values){
super(context, android.R.layout.simple_list_item_1, values);
this.context = context;
}
和
private View createOneView(){
...
}
那麼我
MyArrayAdapter myAdapter = new MyArrayAdapter(this, getAllWatches());
... //DO some stuff here
myAdapter.remove(getAllWatches().get(2));
myAdapter.notifyDataSetChanged();
手錶仍未移除。我懷疑只有在==
而不是.equal()
的情況下才會刪除對象,或者我只是錯過了一些更微不足道的東西?
你想從getAllWatches()中刪除某些東西嗎? – kosa 2012-01-13 22:54:08
我沒有從陣列中移除任何東西。我的意思是,確定元素2將被刪除,但在此測試中,我只是調用.remove,而不修改getAllWatches(),我應該修改它嗎?我不認爲我應該,因爲在初始化後,我猜getAllWatches()被複制到適配器中,而不僅僅是被它引用。 – Paolo 2012-01-13 22:59:38
在實例化適配器之前,爲什麼不移除想要的手錶? – 2012-01-13 23:00:44