java - Soft Keyboard not displaying on touch in WebView DialogFragment -


edit: have looked @ error page this; no answers work. seems android system bug has not yet been solved.

first off i've referred this similar question. solution question not seem solution mine. have dialogfragment contains webview. in webview seems touchable. however, problem when touch form field, cursor appears soft keyboard never shows up!

here's code in oncreatedialog() method within dialogfragment class:

    alertdialog.builder builder = new alertdialog.builder(getactivity());     webview web = new webview(getactivity());     web.loadurl(internetdialog.this.url);     web.setfocusable(true);     web.setfocusableintouchmode(true);     web.requestfocus(view.focus_down);     web.setontouchlistener(new view.ontouchlistener() {         @override         public boolean ontouch(view v, motionevent event) {             switch (event.getaction()) {                 case motionevent.action_down:                 case motionevent.action_up:                     if (!v.hasfocus()) {                         v.requestfocus();                     }                     break;             }             return false;         }     });      builder.setview(web);     return builder.create(); 

how can soft keyboard show when select form field?

this system bug has not yet been fixed. more information can found here. seems though bug occurs differently people , therefore has different solutions. particular case, there 1 solution (as i've tried else). solution:

first, created layout dialog:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical" >  <edittext     android:id="@+id/edit"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:focusable="true"     android:visibility="invisible"/>  <webview     android:id="@+id/web"     android:layout_width="wrap_content"     android:layout_height="wrap_content"/>  </relativelayout> 

then, in dialogfragment class in oncreatedialog method:

    alertdialog.builder builder = new alertdialog.builder(getactivity());     layoutinflater inflater = layoutinflater.from(getactivity());     view v = inflater.inflate(r.layout.internet_dialog, null);      webview web = (webview) v.findviewbyid(r.id.web);     edittext edit = (edittext) v.findviewbyid(r.id.edit);     edit.setfocusable(true);     edit.requestfocus();     web.loadurl(url);     this.webview = web;     builder.setview(v);      return builder.create(); 

and that's there it. reason worked because made edittext gave focus yet made invisible. since edittext invisible doesn't interfere webview , since has focus pulls soft keyboard appropriately. hope helps stuck in similar situation.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -