时间:2022-11-15 09:47:18 | 栏目:Android代码 | 点击:次
自行下载安装,https://developer.android.google.cn/studio/#downloads
package com.lmm.myapp; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends AppCompatActivity { private WebView webView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); webView = new WebView(this); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClientDiy(this)); webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setAppCacheEnabled(true); webView.loadUrl("http://www.sdyztech.com/"); setContentView(webView); } }
package com.lmm.myapp; import android.content.Context; import android.webkit.WebViewClient; public class WebViewClientDiy extends WebViewClient { Context context; public WebViewClientDiy(Context context){ this.context =context; } }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.lmm.myapp"> <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:roundIcon="@drawable/icon" android:supportsRtl="true" android:theme="@style/Theme.AppCompat.Light.NoActionBar"> <activity android:name=".MainActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>