2013-04-25 79 views
0

在我的应用程序中,android 键盘未显示在webview的文本框onfocus中。这是否有任何限制?我在webview touchlistener中尝试了webview.requestFocus()方法。但文本框始终是焦点,键盘并没有显示出来。Android键盘未显示在webview的文本框上onfocus

@Override 
public boolean onTouch(View v, MotionEvent event) { 
    // TODO Auto-generated method stub 
    switch (event.getAction()) { 
    case MotionEvent.ACTION_DOWN: 
    case MotionEvent.ACTION_UP: 
     if (!v.hasFocus()) { 
      v.requestFocus(); 
     } 
     break; 
} 
return false; 

}

我已经设置为在听者onCreate方法为webview.setOnTouchListener(本);

我该如何解决这个问题。

+0

是你在模拟器还是手机中使用 – 2013-04-25 04:48:08

+0

我正在使用手机Android 2.2,4.0.4和4.1.2。 – Karthick 2013-04-25 04:49:39

+0

webView.requestFocus(View.FOCUS_DOWN);试试这个 – 2013-04-25 04:51:55

回答

0

我已经在我的onCreate中像这样实现它,这似乎解决了它。 它基本上与您有相同的代码,但在设置onTouchListener之前添加了_webView.requestFocus(View.FOCUS_DOWN);调用。

_webView.requestFocus(View.FOCUS_DOWN); 
    _webView.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; 
     } 
    }); 
+0

这也不适用于我的。 – Karthick 2013-04-25 05:46:20

0

试试这个打开键盘。

InputMethodManager inputMethodManager = (InputMethodManager) cntx 
       .getSystemService(cntx.INPUT_METHOD_SERVICE); 
     inputMethodManager.toggleSoftInputFromWindow(
       view.getApplicationWindowToken(), 
       InputMethodManager.SHOW_FORCED, 0); 
     view.requestFocus(); 
相关问题