现在我正在尝试这段代码 公共类MainActivity扩展了AppCompatActivity {
private String myPdfUrl = "https://drive.google.com/open?id=1rquwQNdXeds39Rlb32isX3bjYghHitCV/view";
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView=(WebView)findViewById(R.id.ve);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
view.loadUrl(myPdfUrl);
return true;
}
}
);
webView.loadUrl(myPdfUrl);
}
}
但它不起作用
答案 0 :(得分:0)
您尝试使用此代码来加载PDF
String pdfURL = "your url";
webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdfURL);