我正在使用 WebView
从 Android 中的 Google 文档调用表单。当我在模拟器和手机上运行它时,所有 CheckBox
都无法单击。请帮忙。我希望你能弄清楚。谢谢。
这是我的 Activity 类(class)
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>
最佳答案
使用请求焦点能够在 Web View 内单击。
webview.requestFocus(View.FOCUS_DOWN);
关于java - 如何在 Android 中使用 Google 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37581932/