简体   繁体   English

创建供我自己使用的Webview应用的最简单方法?

[英]Simplest way to create a webview app for my own use?

I'm trying to do a simple application that will load a local html file for my Android 3.1 tablet to give presentations on. 我正在尝试做一个简单的应用程序,它将为我的Android 3.1平板电脑加载本地html文件以进行演示。 I'm not a programmer, but I read some tutorials about creating a simple webview app with Eclipse + Android SDK. 我不是程序员,但是我阅读了一些有关使用Eclipse + Android SDK创建简单的Webview应用程序的教程。 But before I get dirty I wanted to know if there was a simpler way of just getting a simple app on my tablet that will in reality just be a full screen web browser. 但是在我变得肮脏之前,我想知道是否有一种更简单的方法在平板电脑上安装一个简单的应用程序,而实际上它只是一个全屏Web浏览器。 Thanks a lot everyone :) 非常感谢大家:)

What's wrong with using a browser that that has a full screen mode? 使用具有全屏模式的浏览器有什么问题? Dolphin has a full screen mode. 海豚具有全屏模式。 Why bother creating an app, especially if you are not a programmer? 为什么要烦恼创建一个应用程序,特别是如果您不是程序员呢?

Simplest way would be using WebView class with default properties. 最简单的方法是使用具有默认属性的WebView类。 You can read more about WebView class on - http://developer.android.com/reference/android/webkit/WebView.html 您可以在以下网站上了解有关WebView类的更多信息: http://developer.android.com/reference/android/webkit/WebView.html

All you need to do is create a xml file that has the layout with the webview widget in it, and inflate it on your onCreate() using setContentView(). 您需要做的就是创建一个XML文件,该文件的布局中包含webview小部件,然后使用setContentView()在onCreate()上对其进行充气。

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

Declare this at class level 在课堂上声明

WebView mWebView;

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

mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(String URL);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM