Reputation: 1839
I have created a chat app that uses RecyclerView
in order to create the messages.
The activity where all of the chat actions are is called ChatActivity
.
In some cases, the RecyclerView
creates a message that contains a Confirm
button.
The button have a listener
to the RecyclerView
and it all works.
I would like that once a user clicked on Confirm
, that the visibility
of the button will be set to GONE
.
I tried to add inside my click listener the following, however it did not hide the buttons.
ChatAdapter.OnConfirmClickListener confirmListener = new ChatAdapter.OnConfirmClickListener(){
@Override
public void onClick(Button confirmB) {
Log.d( "ERROR", "error" );
DocumentReference IsConfirmed = db.collection( "Chats" ).document( chatID );
IsConfirmed
.update( "ConfirmedFlag", auth.getUid() )
.addOnSuccessListener( new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Button confirm = findViewById( R.id.Confirm );
confirm.setVisibility( View.GONE );
Log.d( "WHAT", "DocumentSnapshot successfully updated!" );
}
} )
.addOnFailureListener( new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w( "WHAT", "Error updating document", e );
}
} );
}
};
Any reason that it is not working? I thought maybe there is a problem with View
?
Also, maybe because it was created inside the adapter, it is impossible to set visibility
to GONE
but im not sure.
Thank you
Upvotes: 0
Views: 173
Reputation: 461
Instead:
Button confirm = findViewById( R.id.Confirm );
confirm.setVisibility( View.GONE );
Replace with this:
confirmB.setVisibility( View.GONE );
I hope to be useful
Upvotes: 1