这实际上是可能的,并且可以通过创建您的移动网站的web视图来实现。 假设你知道如何建立一个Android应用程序的结构的基础,在这是你需要什么名为“webview_paceholder”
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview" <!-- The ID of your webview, can be wahtever you want. Just remember it for latter on -->
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
您的主要活动是XML,对您的Java类(如果它被命名为WebView1):
package com.companyname.packagename;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebViewClient;
import android.webkit.WebView;
import android.webkit.JavascriptInterface;
public class WebView1 extends Activity {
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview_paceholder);
mWebView = (WebView) findViewById(R.id.webview); // ID from earlier comment
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://example.com/whateveryourmobileviewis/"); // This url should be the mobile view of your site
mWebView.setWebViewClient(new WebViewClient());
}
如果你不知道一个Android应用程序的基础知识,你可以很快学会做出的Android工作室一个Here Eclipse和Here(推荐)。 希望这有助于!
那么当我没有互联网时会发生什么?我点击这个“应用程序”的图标,只看到一个白色或黑色的屏幕没有?当我点击一个链接将我带到您网站上的另一个页面,并且网络连接不畅时,该怎么办?当我使用网络浏览器时,我期待这些问题,但是如果某个应用程序试图“欺骗”我思考我正在查看应用程序而不是网页,则不会飞行。 – 2014-10-21 21:09:55