【发布时间】:2012-11-11 06:24:33
【问题描述】:
我想从ListView 中删除数据。对于长按事件,我使用了以下代码:
lstGame.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) {
AlertDialog.Builder builder = new AlertDialog.Builder(FavouriteActivity.this);
builder.setMessage("Remove from Favourite?").setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Const.favourite(FavouriteActivity.this, (args[arg2]));
Toast.makeText(FavouriteActivity.this, "Selected Item Removed from Favourite.", Toast.LENGTH_LONG).show();
// Here I get the UnsupportedException---->
// adapter.remove(args[arg2]);
lstGame.setAdapter(adapter);
lstGame.invalidate();
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
Dialog alert = builder.create();
alert.show();
return false;
}
});
为什么会出现这个异常?
【问题讨论】:
标签: android adapter android-arrayadapter