java - 在 android 的 webView 中打开 Url

标签 java android webview

如何打开这个link在 WebView 中。这是在浏览器上运行,但它不在 webView android 中运行。请给出解决方案。

最佳答案

Activity :

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class WebViewActivity extends Activity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        webView = (WebView) findViewById(R.id.webView1);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("http://www.google.com");
    }
}

还有你的 XML:

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

关于java - 在 android 的 webView 中打开 Url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13269059/

相关文章:

Android MapBox 标记偏移

java - 如何从 JavaScriptInterface 启动抽屉导航

java - 如何动态生成接口(interface)的实现

java - 使用不同 SC 系列的智能卡探测 : command to clean the SC state

java - java中检查字符串是否为null

java - Eclipse WTP : "The import ___ cannot be resolved for" error in a JSP file for a class defined in project

java - 关于 android onCreate()c 中数据库 Activity 的问题

java - Baseadapter缓慢且滚动滞后

android - 从 WebBackForwardList 获取 WebView 历史记录

ios - 旋转时 UIWebView 大小不正确