显示软键盘在AlertDialog与内部的WebView(安卓) [英] Show soft keyboard in AlertDialog with a WebView inside (Android)

查看:519
本文介绍了显示软键盘在AlertDialog与内部的WebView(安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序创建一个 AlertDialog 具有的WebView 里面。该的WebView 加载一个网页,需要用户登录。然而,当我点击了的WebView文本字段 ,软键盘不会出现。我知道一般的问题(安卓发行7189 )的;然而,在我的情况下,建议的解决方案似乎没有工作,因为我使用一个外部网站,而不仅仅是一个简单的HTML表单。

In my Android app I create an AlertDialog that has a WebView inside. The WebView loads a webpage that requires the user to log in. However, when I click on text fields in the WebView, soft keyboard does not appear. I am aware of the issue in general (Android: Issue 7189); however, in my case the suggested solution does not seem to work since I use an external website, and not just a simple HTML form.

完美的解决方案是,如果当用户点击了网站的文本字段的键盘出现。然而,具有键盘加上 AlertDialog 也将工作出现。任何想法?

The perfect solution would be if the keyboard appeared when the user clicked on the website's text fields. However, having the keyboard appear together with theAlertDialog would also work. Any ideas?

推荐答案

看来,最好的解决办法是简单地创建一个自定义对话框。定制对​​话框似乎不具有所有的软键盘臭虫(它显示了什么时候它必须)。下面是一些基本的code:

It seems that the best solution is to simply create a custom dialog. Custom dialogs do not appear to have the soft keyboard bug at all (it shows up exactly when it has to). Here's some basic code:

Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dialog.setContentView(R.layout.dialog);
dialog.setTitle("My great title");
dialog.setCancelable(true);

dialog.show();
dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon);

WebView vw = (WebView) dialog.findViewById(R.id.wv);

这篇关于显示软键盘在AlertDialog与内部的WebView(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆