Ben Noland
Ben Noland

Reputation: 34948

Display a Comment Input and Button at the Bottom of the Screen onClick

I have some items in a RecyclerView that I'm displaying in a couple of different Fragments within my app. The items have a Comment button. When the user taps the button, I'd like to show an EditText and a Button at the bottom of the screen so they can enter their comment and press "Send".

I'm thinking I should programmatically create a new ConstraintLayout, add it to the bottom of my current ConstraintLayout, and then create a new EditText and new Button to put inside.

I need to be able to use this comment input mechanism from a couple of different places within my app.

Is this a good approach?

Upvotes: 0

Views: 193

Answers (1)

ked
ked

Reputation: 77

Just a suggestion - From what you have described, it looks like you want some kind of bottom sheet with an edit text and a send button. You can achieve this using a bottom sheet like one shown in this post : Show entire bottom sheet with EditText above Keyboard

I think of this just like a dialog fragment with a property that will be passed from your recycler view's view holder and tracked for that specific item in the recycler view. Once submitted the text using send button, you can update your recycler view item by having a callback directly from the bottom sheet or save the response in the db if you're using room. Even better if you're recycler view is hooked directly with the table (or joined tables) in room database using LiveData. This way you don't even need any callback.

Upvotes: 1

Related Questions