Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to delete item #84

Closed
jumamz opened this issue Feb 20, 2016 · 9 comments
Closed

how to delete item #84

jumamz opened this issue Feb 20, 2016 · 9 comments

Comments

@jumamz
Copy link

jumamz commented Feb 20, 2016

No description provided.

@puf
Copy link
Contributor

puf commented Feb 20, 2016

If a user clicks/taps on an item, you'll get the position of that item from Android.

With that you can call adapter.getRef(position).remove().

@puf puf closed this as completed Feb 20, 2016
@joemerritt
Copy link

Puf, how can you delete the item from the viewholder?

@astromme
Copy link

@puf, I'm also wondering how you delete the item from the viewholder? Seems like the viewholder doesn't know about the adapter.

@SUPERCILEX
Copy link
Collaborator

@astromme Simply create a DatabaseReference setter in your viewholder:

public void setRef(DatabaseReference ref) {
    mRef = ref;
}

// Do other stuff like setting a click listener

@farouqBenarous
Copy link

Yes Me to I have the same probleme i want to delete only from the View (recyclerview ) and not for the database ! any solutions ! ?

@driexyz
Copy link

driexyz commented Nov 28, 2018

i have an item using a relative layout for view holder in recycleview, it have an id to declare it in code. so when populating view to bind the data on viewholder i just need to call removeAllViewsInLayout() to make it dissapear from recycleview and not delete the real data on firebase.

@rashidullahk
Copy link

this is who can solve my problem i tired to much

@rashidullahk
Copy link

    mRef.addChildEventListener(new ChildEventListener() {
        @Override
        public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

            CourseModel courseModel=dataSnapshot.getValue(CourseModel.class);
            courseModelslist.add(courseModel);
            arrayKeyList.add(dataSnapshot.getKey());
            courseAdapter=new CourseAdapter(RetriveCourse.this,courseModelslist);
            recyclerView.setAdapter(courseAdapter);
            courseAdapter.notifyDataSetChanged();

// for (DataSnapshot ds:dataSnapshot.getChildren())
// {
// CourseModel courseModel=ds.getValue(CourseModel.class);
// courseModelslist.add(courseModel);
//
// }
// courseAdapter=new CourseAdapter(RetriveCourse.this,courseModelslist);
// recyclerView.setAdapter(courseAdapter);
// courseAdapter.notifyDataSetChanged();

        }

        @Override
        public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

        }


        public void onChildRemoved(@NonNull DataSnapshot dataSnapshot) {

       //     String key=dataSnapshot.getKey();


        }

        @Override
        public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

        }

        @Override
        public void onCancelled(@NonNull DatabaseError databaseError) {

        }
    });

how to delete data from recyclerview and also from firebase database.....i used customer adapter extends from recyclerview adapter ....plz help me anyone

@LukeDaniel16
Copy link

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants