私のコードにはListActivity
があります。リストアイテムのコンテキストメニューオプションの1つが「削除」で、アクションを確認するダイアログが開きます。私は最初にデータベース内のアイテムのデータを削除してからArrayAdapter
から削除することで、この機能を実装しようとしました。それは私が感謝すべてのヘルプUnsupportedOperationException
...ArrayAdapter.removeを使用したUnsupportedOperationException
public void onClick(DialogInterface dialog, int id)
{
asynchronousDeleteEntry(CONTEXT_SELECTED_ID);
dialog.dismiss();
//I -know- that the adapter will always be an object
//of ArrayAdapter<JournalEntry> because this is the only type
//I ever call setListAdapter with. Debugging confirms this
@SuppressWarnings("unchecked")
final ArrayAdapter<JournalEntry> adapter = (ArrayAdapter<JournalEntry>)
journalViewerListActivity.this.getListAdapter();
//EXCEPTION OCCURS HERE
adapter.remove(adapter.getItem(CONTEXT_SELECTED_POSITION));
//refreshes the ListView to show the new items
adapter.notifyDataSetChanged();
を得ることArrayAdapter
から削除しています。 ありがとう!
"最終"の意味ではありません。これはC++の "const"と同じではありません。 – mhsmith