Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.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 如何在Android中使用谷歌表单_Java_Android_Android Webview_Google Docs_Google Forms - Fatal编程技术网

Java 如何在Android中使用谷歌表单

Java 如何在Android中使用谷歌表单,java,android,android-webview,google-docs,google-forms,Java,Android,Android Webview,Google Docs,Google Forms,我正在使用WebView从Android中的谷歌文档中调用一个表单。当我在模拟器和手机上运行它时,所有的复选框都不能被点击。请帮忙。我希望你能弄明白。多谢各位 这是我的活动课 package com.example.nevigrof.ymuc; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; import android.webkit.WebViewClient; pub

我正在使用
WebView
从Android中的谷歌文档中调用一个表单。当我在模拟器和手机上运行它时,所有的
复选框都不能被点击。请帮忙。我希望你能弄明白。多谢各位

这是我的活动课

package com.example.nevigrof.ymuc;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class SurveyForm extends Activity {
    private class MyWebViewClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
        }
    }
    WebView webview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_survey_form);

        webview = (WebView) findViewById(R.id.webview1);
        webview.setWebViewClient(new MyWebViewClient());
        openURL();
    }

    private void openURL() {
        webview.loadUrl("thegoogleformiwanttobrowse");

    webview.requestFocus();

    }
}
这是我的布局xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.nevigrof.ymuc.SurveyForm">

    <WebView
        android:id="@+id/webview1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true" />
</RelativeLayout>

使用请求焦点可以在webview中单击

webview.requestFocus(View.FOCUS_DOWN);

希望这有帮助,您可以尝试:

在Webview布局中添加android:focusable=“true”

添加
Webview.requestFocus(View.FOCUS\u DOWN | View.FOCUS\u UP)

编辑:如果两个解决方案仍然不起作用,请尝试:

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;
    }
});


您应该在webview中启用javascript:

webview.getSettings().setJavaScriptEnabled(true);

我刚才做了,先生,但它仍然不可点击谢谢先生,但我不明白,我将把这个代码放在哪里,我把它插入了我的代码中,但它给了我错误。谢谢先生,这是我的错误,再次谢谢先生提醒。这很有帮助,先生,但上面说,一旦我赢得15个声誉,我的选票就会显示出来。也许我只是一个新用户。还有一件事,先生,我使用了字符串webUrl=webview.getUrl();所以我可以吐司的网址,它的工作,facebook的网址显示在吐司消息,但当我登录没有网址吐司。高保萨那妈干杯。有什么建议吗,先生?我建议发布一个新问题。请添加相关代码。
webview.getSettings().setJavaScriptEnabled(true);