简体   繁体   中英

Showing Keyboard with Android Dialog

I want to show the Android version of a Model Dialog with text input however I think the keyboard will be behind the actual activity since dialogs weren't made to have inputs. Is there any way I can get the keyboard to show in an actual dialog.

I did see this SO question -- however I'd rather not use an Theme.Dialog'ed activity because I feel like an activity would be too heavy for my purposes. How can I show this Model Dialog with the keyboard input in the foreground?

This is what I am talking about: 替代文字

Who said dialogs aren't made to have inputs?! A dialog can contain anything - text, buttons, progress bars, input fields. Did you try it out? A keyboard resizes your canvas, so there's no "behind"/"front" going on. (Besides, you can always summon the IME on a phone without a QWERTY keyboard by holding the menu button - even there's a modAl dialog.)

EDIT: If you need proof, just look at the API Demos (App -> Dialog). There's an example for a dialog with text entry. Source code here: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlertDialogSamples.html (DIALOG_TEXT_ENTRY)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM