简体   繁体   English

在Webview应用中点击文本框不会显示软键盘

[英]Tapping textfield in webview app does not show soft keyboard

in my webview app some textfields are there in the site,but tapping on it does not show soft keyboard.Some grey colored part is coming in the lower side of the display and looks like the keyboard is hiding behing .please help me to solve this problem. 在我的Webview应用程序中,网站上存在一些文本字段,但点击它不会显示软键盘。显示屏的下部出现一些灰色部分,看起来键盘在隐藏蜂鸣声。请帮助我解决这个问题问题。

WebActivity.java WebActivity.java

package com.example.samworkshops;



import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebActivity extends Activity {
    public WebView webview;


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
         webview = (WebView) findViewById(R.id.webview);
        webview.setWebViewClient(new WebViewClient());
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setUseWideViewPort(true);
        webview.getSettings().setLoadWithOverviewMode(true);
        webview.loadUrl("http://app.samworkshops.org");

    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // Check if the key event was the Back button and if there's history
        if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
            webview.goBack();
            return true;
        }
        // If it wasn't the Back key or there's no web page history, bubble up to the default
        // system behavior (probably exit the activity)
        return super.onKeyDown(keyCode, event);
    }
}

you can do something like this, please see this updated answer 您可以执行以下操作,请查看此更新的答案

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:

                v.requestFocusFromTouch(); 

            break;
        }
        return false;
    }
});

please visit http://code.google.com/p/android/issues/detail?id=7189 请访问http://code.google.com/p/android/issues/detail?id=7189

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM