Need some basic info to develop mobile website in Android
I would like to 开发者_运维问答develop an Android app to access our web site. How can I do this?
see here: Web Applications
This is a very broad question. However, at the highest level, you're most likely going to want to add an interface to your website that supports either JSON or XML as a means to request information. You would then configure your application to request the JSON or XML, parse it, and display it, rather than the user viewing the HTML that is currently served. Alternatively, you could develop a version of your site that is designed to be viewed on the device.
You can use WebView in your application to show your website. WebView it is a widget built into android using it to display html content. Enable the internet access through the Manifest file.
Adding a WebView to Your Application
To add a WebView to your Application, simply include the element in your activity layout. For example, here's a layout file in which the WebView fills the screen:
<?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"
/>
To load a web page in the WebView, use loadUrl(). For example:
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.example.com");
精彩评论