我想从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;
}
});
为什么我会得到那个例外?