したがって、アクティビティにはリストビューとグリッドビューがあります。どちらにもカスタムアダプターがあります。DragAction.Drop が実行されると、アクションを確認するアラートが表示されます。ユーザーがこれを確認したら、データベース内の一部のデータを変更します。データが変更されたので、リストビューを更新する必要があります。メソッドは既に存在しますが、アクティビティの一部です。アダプタでのドロップ時に実行する必要があるアラートおよびその他のアクションを実行します。そのため、ドロップのアクションが完了したことをアクティビティに伝える必要があります。したがって、アクティビティは refresh メソッドを呼び出すことができます。
これは、アダプターの DragAction.Drop からの私のコードです。
case DragAction.Drop:
truckNumber = e.Event.ClipData.GetItemAt (0).Text;
truckLabelText = e.Event.ClipDescription.Label;
AlertDialog.Builder alertBuilder = new AlertDialog.Builder (context);
alertBuilder.SetTitle ("Please confirm");
alertBuilder.SetMessage ("Are you sure you want to assign Truck: " + truckNumber + " to Dock: " + dockName.Text + "?");
alertBuilder.SetPositiveButton ("Yes", async delegate {
currentTruck.SetText (truckNumber, TextView.BufferType.Normal);
truckLabel.SetText (truckLabelText, TextView.BufferType.Normal);
await _DataLayer.changeTruckStatusCode (Convert.ToInt32 (truckNumber), 3);
});
alertBuilder.SetNegativeButton ("No", delegate {
});
alertBuilder.Show ();
e.Handled = true;
break;
}
};
dockName.SetText (item.name.ToString (), TextView.BufferType.Normal);
currentTruck.SetText ("", TextView.BufferType.Normal);
truckLabel.SetText ("", TextView.BufferType.Normal);
return view;
}