开发者

Automatically get keyboard for an EditText in a Dialog (Android)

开发者 https://www.devze.com 2023-04-13 01:42 出处:网络
Close cousins of this question seem to be all over StackExchange, but maybe that\'s why I can\'t find an answer...

Close cousins of this question seem to be all over StackExchange, but maybe that's why I can't find an answer...

I have an application. Within the application, I've got a couple different Surface Views, and each of them has a couple different actions that fire up a Dialog.

My dialogs consists of an EditText (for typing in some data) and Set and Cancel buttons for acting on that data. To type in the data, the user first touches the EditText to bring 开发者_开发技巧up the keyboard, then types the data, touches Done, then touches Set, and the application continues on its merry way.

I would like to find a way to shorten this, if at all possible. Specifically, I would like to skip over the view of the dialog and go right to the view of the keyboard. (Essentially, I want to programmatically "touch" the EditText, if that makes any sense.)

Like I said at the beginning of this, I'm not having a lot of luck, so any suggestions will be happily looked in to. And, unfortunately, simply requesting focus in the EditText has been tried and hasn't done the trick...

R.


Try this

 dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);


The easy and best way , is to give focus to your EditText when your open the dialogues :

EditText yourET = (EditText) findViewById(R.id.my_editText);
yourET.requestFocus();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号