一个网站转换为Android应用程序 [英] Convert a website to an android application

查看:105
本文介绍了一个网站转换为Android应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建在asp.net C#站点。 Visual Studio 2010中。

I built a site in asp.net C#. Visual Studio 2010.

该网站尺度很好,适合我的手机和其他Android divices。它的数据库驱动也。我想为在Android Market的应用程序从我的网站现在。免费的应用程序。

The site scales nicely and fits on my phone and other Android divices. It database driven also. I want to make an app for the android market out of my site now. Free app.

我可以很容易地做到这一点?可以在应用程序很简单,如启动浏览器窗口?将Android的市场接受一个应用程序那样?

Can i easily accomplish this? Can a app be as simple as launching a browser window? Will the android market accept an app like that?

点我在正确的方向吧。林不能确定从哪里开始。

Point me in the right direction please. Im unsure where to start.

推荐答案

您介绍可以使用易于实现什么的WebView

What you describe can be easily accomplished using a WebView.

的WebView (从 Android开发:A查看显示的网页。这个类是基础,使你可以推出自己的网络浏览器或只显示你的活动中的一些在线内容。它使用了WebKit渲染引擎来显示网页和包含方法来浏览向前和向后的历史,放大和缩小,执行文本搜索等。

WebView (from android developers) : A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.

下面是一个简单的示例应用程序:

Here's a simple sample app:

public class WebActivity extends Activity {

    WebView mWebView;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        final Activity mActivity = this;
        super.onCreate(savedInstanceState);

        // Adds Progrss bar Support
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.main);


        // Makes Progress bar Visible
        getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

        mWebView = (WebView) findViewById( R.id.webview );
        mWebView.getSettings().setJavaScriptEnabled(true);     
        mWebView.loadUrl(http://your.url.com);


        mWebView.setWebChromeClient(new WebChromeClient() 
        {
            public void onProgressChanged(WebView view, int progress)  
            {
                //Make the bar disappear after URL is loaded, and changes string to Loading...
                mActivity .setTitle("Loading...");
                mActivity .setProgress(progress * 100); //Make the bar disappear after URL is loaded

                // Return the app name after finish loading
                if(progress == 100)
                {
                    financialPortalActivity.setTitle(R.string.yourWebSiteName);
                }
            }
        });
    }
}

和一个非常简单的布局文件:main.xml中

and a very simple layout file: main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <WebView 
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    />
</LinearLayout>

当然,你必须在你的清单设置权限:

Of course you will have to set a permission in your Manifest:

 <uses-permission android:name="android.permission.INTERNET" />

这篇关于一个网站转换为Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆