0
@Override  
 public boolean onContextItemSelected(MenuItem item) {  
  if(item.getTitle()=="Remove"){
   AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
   quotesAdapter.remove(quotes.get((int)info.id));
   quotesAdapter.notifyDataSetChanged();
   listView.setAdapter(quotesAdapter);
   serializeQuotes();
  }  
  else {
   return false;
  }  

  return true;  
 }  

Doesn't do anything. If I add

this.quotesAdapter = new QuoteAdapter(this, R.layout.mainrow, quotes);

Removal works, but I don't think is the right way of doing things. I'm not sure what is wrong?

4

1 回答 1

0

如果quotes是 Java 数组,则在运行时不可修改。尝试使用 anArrayList<>代替。

如果quotesCursor,则需要从底层数据库中删除该行,requery()那么Cursor.

于 2010-08-31T23:17:32.637 回答