2013-04-25 52 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(); 
相關問題