【发布时间】:2014-07-23 05:52:10
【问题描述】:
我有一个使用 webview 的 android 应用程序。 我正在使用的几种形式对第一个元素具有自动对焦。 我想要的是在加载表单时显示相关的键盘。活动中的代码是:
public class MyActivity extends DroidGap {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//load the main app
loadUrl("file:///android_asset/www/index.html");
}
@Override
public void init() {
final String version = getVersion();
CordovaWebView webView = new CordovaWebView(this);
init(webView, new CordovaWebViewClient(this, webView) {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
super.onPageFinished(view, url);
boolean redirected = false;
//If the page you're accessing is the login page
if (url.endsWith("/Login")) {
//redirect to root page with query string
appView.loadUrl(url + "?version=" + version));
redirected = true;
}
return redirected;
}
}, new CordovaChromeClient(this, webView));
}
}
基本上,在应用程序的索引页面上方的代码中发生了什么被加载。当我单击登录按钮时,应用程序版本将附加到加载的 url(出于不相关的原因)并显示登录页面。 当页面加载时,我可以看到该字段内的光标,但在我按下该字段之前不会显示键盘。
我查看了this question,但不知道如何应用答案。 非常感谢您的任何帮助。
【问题讨论】: