我见过很多手机应用程序只是打开一个网页而没有控件。只是页面。
我正在寻找指导和链接来开始这样简单的事情。
如果您想在 Android 中封装一个网站,您可以使用以下代码来实现:Roskvist https://roskvist.wordpress.com/tag/wrap-website/
package com.webview;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView;
public class WebViewTest extends Activity {
WebView browserView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Removes the title bar in the application
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
//Creation of the Webview found in the XML Layout file
browserView = (WebView)findViewById(R.id.webkit);
//Enable Javascripts
browserView.getSettings().setJavaScriptEnabled(true);
//Removes both vertical and horizontal scroll bars
browserView.setVerticalScrollBarEnabled(false);
browserView.setHorizontalScrollBarEnabled(false);
//The website which is wrapped to the webview
browserView.loadUrl("http://dev.openlayers.org/sandbox/camptocamp
/mobile/trunk/examples/iol-iui.html?rev=9962#_map");
}
}
这是 main.xml 内容
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView
android:id = "@+id/webkit"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
然后您必须编译它并通过 USB 将其加载到您的设备上。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)