Issue
i wrote a function that opens a webView inside of a dialog, the problem is that the keyboard doesnt pop up when i click a textArea i tried all the solutions in this thread to no avail
this code is function in a android.support.v4.app.Fragment
public void openWebView() {
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this.getActivity());
WebView webView = new WebView(this.getActivity());
webView.loadUrl("http://www.google.com");
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
alertBuilder.setView(webView);
webView.getSettings().setJavaScriptEnabled(true);
alertBuilder.show();
}
this is the log when i press the text area a few times:
09-15 11:44:56.165 27483-27542/ngapps.socialbackground D/webcoreglue﹕ WebViewCore::nextTextOrSelectNode : nextNode is NULL
09-15 11:44:56.165 27483-27542/ngapps.socialbackground D/webcoreglue﹕ WebViewCore::previousTextOrSelectNode : !previousNode )
09-15 11:45:04.715 27483-27542/ngapps.socialbackground D/webview﹕ blockWebkitViewMessage= false
09-15 11:45:04.720 27483-27542/ngapps.socialbackground D/webcoreglue﹕ WebViewCore::nextTextOrSelectNode : nextNode is NULL
09-15 11:45:04.720 27483-27542/ngapps.socialbackground D/webcoreglue﹕ WebViewCore::previousTextOrSelectNode : !previousNode )
09-15 11:45:04.720 27483-27542/ngapps.socialbackground D/webcoreglue﹕ WebViewCore::nextTextOrSelectNode : nextNode is NULL
09-15 11:45:04.720 27483-27542/ngapps.socialbackground D/webcoreglue﹕ WebViewCore::previousTextOrSelectNode : !previousNode )
Solution
You can define fake keyboard like this:
AlertDialog.Builder alert = new AlertDialog.Builder(this);
WebView wv = new WebView(this);
LinearLayout wrapper = new LinearLayout(this);
EditText keyboardHack = new EditText(this);
keyboardHack.setVisibility(View.GONE);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl(loadUrl);
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
wrapper.setOrientation(LinearLayout.VERTICAL);
wrapper.addView(wv, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
wrapper.addView(keyboardHack, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
alert.setView(wrapper);
Answered By - Burak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.