How do I edit a Child in firebase?

Asked

Viewed 694 times

0

In the case then I make a comment and recover, I wondered how to edit this Child,the comment carries more information as user uid photo and name... more not put here.

  FirebaseRecyclerAdapter<Cont, BloviewHolderr> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Cont, BloviewHolderr>(

            Cont.class,
            R.layout.coment_row,
            BloviewHolderr.class,
            mQueryCurrentUser

    ) {
        @Override
        protected void populateViewHolder(BloviewHolderr viewHolder, Cont model, int position) {
            final String user_key = getRef(position).getKey();
            //viewHolder.set_nome(model.getName());
            viewHolder.setComentario(model.getComentario());
            viewHolder.setUsername(model.getUsername());
            viewHolder.setData(model.getData());
            viewHolder.setFtperfil(getApplicationContext(), model.getFtperfil());

            viewHolder.mView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent singleBlogIntent = new Intent (Comentarios.this, Perfil.class);
                    singleBlogIntent.putExtra("blog_id", user_key);
                    startActivity(singleBlogIntent);

                }
            });


        }

    };
    mSingleComentBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            final String coment_val = mSingleBlogComent.getText().toString().trim();


                            if (!TextUtils.isEmpty(coment_val)) {



                final String user_id = mAuth.getCurrentUser().getUid();
                final String post_key = getKey();
                final DatabaseReference newComent = mDatabaseComent.push();
                mDatabaseUser.addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {

                        newComent.child("comentario").setValue(coment_val);

                    }


                    @Override
                    public void onCancelled(DatabaseError databaseError) {

                    }
                });

            }

        }
    });
    mComentList.setAdapter(firebaseRecyclerAdapter);

}

public static class BloviewHolderr extends  RecyclerView.ViewHolder{

    View mView;

    public BloviewHolderr(View itemView) {
        super(itemView);

        mView = itemView;
    }
    public void setComentario (String comentario) {
        TextView post_coment = (TextView) mView.findViewById(R.id.messageComent);
        post_coment.setText(comentario);
      }}

My Questions Without Answers:Problem in recovering data in map (Firebase)

My Questions Without Answers:Problem recovering with Firebase

1 answer

0


After retrieving the comment, you use the same path you recovered to publish again. The comment will be replaced.

  • understand...how do i re edit? type appear editText

  • You can repeat the method you used to comment the first time. On the click, it calls the database if you change the value. Here the Listener will be called (wherever you are) and there you can get the changed value. depends on what you need to do. As in the other question, you are putting your Listerne in the wrong place. Cut it out and put it out of that onclickai

  • Please explain to me this part of Listener I’m overshadowed.

  • Thank you cleared my mind!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.