0

I am currently following a video wherein an he created a deleteclick event in the adapter to delete a certain item. What is the right syntax in only deleting the item in adapter without deleting it from the firebase?

This is the adapter click event:

private void Eventadapter_DeleteItemClick(object sender, EventAdapterClickEventArgs e)
        {
            string eventkey = EventList[e.Position].eventID;

            SupportV7.AlertDialog.Builder deleteevent = new SupportV7.AlertDialog.Builder(this);
            deleteevent.SetTitle("Delete Reserved Event");
            deleteevent.SetMessage("Are you sure? This will also delete the client.");
            deleteevent.SetPositiveButton("Continue", (deleteAlert, args) =>
            {
                //Delete Client from the database
                eventListener.DeleteEvent(eventkey);
                Intent intentz = new Intent(this, typeof(event_activity));
                intentz.AddFlags(ActivityFlags.NoAnimation);
                this.Window.TransitionBackgroundFadeDuration = 0;
                StartActivity(intentz);
            });

            deleteevent.SetNegativeButton("Cancel", (deleteAlert, args) =>
            {
                deleteevent.Dispose();
            });

            deleteevent.Show();
        }

The Listener for retrieving inputted data and display on the recyclerview

        public void DeleteEvent(string key)
        {
            DatabaseReference reference = AppDataHelper.GetDatabase().GetReference("eventreserved/" + key);
            reference.RemoveValue();
        }

I tried removing the DeleteEvent method but didn't work. I also tried calling the item adapter but also didn't work. What is the right syntax for this? Thank you for future answers. I appreciate it! :)

Zeno
  • 11
  • 3
  • You can check this about the [How to remove items from recyclerview adapter](https://stackoverflow.com/questions/61209320/how-to-remove-items-from-recyclerview-adapter) . And here is the document about the [RecyclerView.Adapter](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter). – Guangyu Bai - MSFT Nov 25 '22 at 07:49
  • Thank you for the reply but I am currently using C# language and I don't know how the syntax of the said code on the post. Sorry but thank you I appreciate your reply. I am gonna start reading about the document thank you! – Zeno Nov 25 '22 at 19:45

0 Answers0