Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java WebView--无法在google文本框中写入_Java_Android_Webview_Android Webview - Fatal编程技术网

Java WebView--无法在google文本框中写入

Java WebView--无法在google文本框中写入,java,android,webview,android-webview,Java,Android,Webview,Android Webview,已编辑-图像链接: 我在webview中创建了一个简单的web浏览器,如图所示。我能够通过点击网站或在文本栏(GO按钮左侧)中写入url来浏览网站,但不能在webview中写入,即不能在搜索框中写入,如图所示 这是我的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layo

已编辑-图像链接:

我在webview中创建了一个简单的web浏览器,如图所示。我能够通过点击网站或在文本栏(GO按钮左侧)中写入url来浏览网站,但不能在webview中写入,即不能在搜索框中写入,如图所示

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="10" >

        <EditText
            android:id="@+id/etURL"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2" >
        </EditText>

        <Button
            android:id="@+id/bGo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="8"
            android:text="Go" >
        </Button>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="8" >

        <Button
            android:id="@+id/bBack"
            android:layout_width="115dp"
            android:layout_height="wrap_content"
            android:text="Back" >
        </Button>

        <Button
            android:id="@+id/bForward"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Forward" >
        </Button>

        <Button
            android:id="@+id/bRefresh"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="8"
            android:text="Refresh" >
        </Button>
    </LinearLayout>

    <WebView
        android:id="@+id/WebEngine"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="17.26" />


</LinearLayout>

终于在下面的链接中找到了答案


你可以上传图片到其他网站,然后从这里链接到它们。谢谢你的建议。。。我在编辑:OK中添加了图像链接。现在,你说“不能在搜索框中书写”是什么意思?“在搜索框中写东西”你具体做了什么?我点击了谷歌文本框。现在单击文本框光标开始闪烁,但当我在编辑框(go按钮左侧)键入它时,任何有用的评论或澄清都将不胜感激。
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;
            }
        });