search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

[Android] Android Studuo 使用Html

示範
先新增Assect Folder->Finish
接著新增File->index.html
XML
xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <WebView
        android:id="@+id/webv"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
android.support.constraint.ConstraintLayout>
JAVA
public class MainActivity extends AppCompatActivity{
    WebView webv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String myuri="file:///android_asset/index.html";
        webv=(WebView)findViewById(R.id.webv);
        webv.getSettings().setJavaScriptEnabled(true);
        webv.loadUrl(myuri);
    }
}


熱門推薦

本文由 kk665403pixnetnetblog 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦