Android Studio: Can I use EditText in my game? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Android Studio: Can I use EditText in my game?

Hi, I'm developing a game using Android Studio. In the game I need to get players' input (like writing down username and password or chatting with others), but I wonder if I can create an EditText programmatically, since I am using no layouts in my game and I'm drawing everything to the Canvas. I tried to draw an EditText on the canvas using its draw(Canvas canvas) method, but it's not drawn to the screen.. Here's how I'm trying to create an EditText: editText = new EditText(context); editText.setPadding(0, 0, 100, 40); And I render it with draw(canvas).... Is there something else I should add?

27th Apr 2019, 4:06 PM
Robert Sokolov
Robert Sokolov - avatar
2 Answers
+ 1
maybe using popup ? you can design the view like normal
27th Apr 2019, 4:42 PM
Taste
Taste - avatar
0
As far as a the log-in form is considered, a popup would be enough. But I can't use a popup for chatting... I've seen in many android games, that when they want to have the user type something in or chat with other players, they use their own Textfield which shows the keyboard when you tap on it. The keyboard appears along with an EditText where you can type, copy, paste and all that stuff, while the Textfield is displaying the text.... Can you tell me how can I do that? I know how to show the keyboard, but I want to know hoe to attach an EditText onto it... Thanks!
27th Apr 2019, 9:00 PM
Robert Sokolov
Robert Sokolov - avatar