いくつかのアプリを書いていて、マップからアイテムを削除するのに行き詰まりました。これは私のコードからの関連スニペットです。
protected boolean onTap(final int index) {
tapped=true;
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle("Remove Item");
dialog.setMessage("Are you sure you want to Remove this Item?");
dialog.setNegativeButton("No", null);
dialog.setPositiveButton("Yes", new OnClickListener() {
@SuppressWarnings("unchecked")
@Override
public void onClick(DialogInterface arg0, int arg1) {
mOverlays.remove(index);
ItemOverlay.this.populate();
ItemOverlay.this.setLastFocusedIndex(-1);
ItemOverlay.this.setFocus(null);
}
});
dialog.show();
return true;
}
ご覧のとおり、タップしたアイテムを削除し、フォーカスが合っていないことを確認しましたが、ユーザーが画面の別のポイントをタップするか、マップをスクロールするまで、削除したアイテムは引き続き描画されます。
他に何を試すべきですか?