I am a beginner in android studio (java) and I'm making a Hotel Reservation App. I have three types of rooms (Single, Deluxe, Suite). Each of the rooms has buttons that will redirect to a Reservation form https://i.stack.imgur.com/rXAWj.png. I want to take a string("Single", "Deluxe", "Suite"), depending on the button pressed then display it on the "Room Type" as seen on the image provided.
Asked
Active
Viewed 56 times
0
-
just put yourEditText.setText("Single"). (or "deluxe", "suite") – FelipeCruzV10 Jun 05 '21 at 08:22
-
please show us what you have tried – Elango Jun 05 '21 at 09:13
3 Answers
0
there are two straight forward ways to deal with your situation.
- if you are opening the form in a new fragment/activity, you can just pass the data. For detail, you can refer to https://stackoverflow.com/a/16036693/9635486
- or you can just change the
Room Type
editText to a Spinner so that it can be handled within the same fragment

Neo Luk
- 446
- 4
- 10
0
First i dont know whick language you are working on it i answer it as a kotlin set for every button onclick listener like this
(buttonSingle.setOnClickListener {},buttonDeluxe.setOnClickListener, buttonSuite.setOnClickListener{})
and then write inside of these blocks for example inside of button single button
val myString = single.text(in java getText).toString
and write it in your edittext with
edittextRoom.text(in java setText) = myString
this is all you need

Barney Stinson
- 212
- 3
- 12
0
Create a dropdown list(for >3 options) or radio button(for ≤3 options) instead of getting input from user .it will more convenient way to show options

Code Scan
- 42
- 8