我用 asp.net C# 建立了一个站点.视觉工作室 2010.
I built a site in asp.net C#. Visual Studio 2010.
该网站可以很好地扩展,适合我的手机和其他 Android 设备.它也是数据库驱动的.我现在想从我的网站上为安卓市场制作一个应用程序.免费应用.
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.
我可以轻松做到这一点吗?应用程序可以像启动浏览器窗口一样简单吗?安卓市场会接受这样的应用吗?
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 开发者) :显示网页的视图.这个类是你可以滚动你自己的网络浏览器或简单地在你的活动中显示一些在线内容的基础.它使用 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 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!