我想从asset文件夹加载.我试着跟随和谷歌搜索.但是,我的文件没有加载.它说"网页不可用"
这是我的代码:
HelpActivity.java
public class HelpActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
((WebView) findViewById(R.id.webView1))
.loadUrl("file///android_asset/help.html");
}
public void closeWindow(View v) {
finish();
}
}
Run Code Online (Sandbox Code Playgroud)
help.xml
<LinearLayout 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"
android:orientation="vertical"
tools:context=".HelpActivity" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</WebView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
help.html
<html>
<body>
Hello world
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我应该在AndroidManifest中包含任何权限吗?
android ×1