青儿广场舞新草原情歌:jquery mobile - Android 问题解答

来源:百度文库 编辑:九乡新闻网 时间:2024/05/03 11:09:42
将js的api文档集成到android项目中,简单而且实用。这个时候,你就可以不再用原生态的UI了。通过HTML + JS +css  你可以做出各种各样的UI
     需要注意到是,用这种方式开发程序,软件的运行效率会比原生态UI慢,但是UI界面更加美观和灵活变动。
第一步: 到http://jquerymobile.com/ 下载最新的 JQuery 的API 包

第二步: 将下载好的文件解压,放到android项目的assets文件夹中。

第三步: 在assets文件夹下新建一个sample文件夹。并在sample文件夹中新建一个index.html文件
    index.html文件的内容如下:
    
view plaincopy to clipboardprint?
1.        
2.        
3.            
4.            ;Page Title
5.            rel="stylesheet"
href="../jquery/jquery.mobile-1.0a1.min.css"
mce_href="jquery/jquery.mobile-1.0a1.min.css"
/>
6.            src="../jquery/jquery-1.4.3.min.js"
mce_src="jquery/jquery-1.4.3.min.js">
7.            src="../jquery/jquery.mobile-1.0a1.min.js"
mce_src="jquery/jquery.mobile-1.0a1.min.js">
8.        
9.        
10.        data-role="page">
11.            data-role="header">
12.               

;Page Title


13.            

14.            data-role="content">
15.               

;Page content goes here.


16.            

17.            data-role="footer">
18.               

;Page Footer


19.            

20.        

21.        
22.        

第四步:编辑main。xml的内容如下
   
view plaincopy to clipboardprint?
1.        version="1.0"
encoding="utf-8"?>
2.        xmlns:android="http://schemas.android.com/apk/res/android"
3.            android:orientation="vertical"
android:layout_width="fill_parent"
4.            android:layout_height="fill_parent">
5.            android:id="@+id/webView01"
android:layout_width="fill_parent"
6.                android:layout_height="wrap_content"
/>
7.        

第五步,编辑myActivity.java的内容如下:
    
view plaincopy to clipboardprint?
1.        package com.geolo.android;  
2.        import android.app.Activity;  
3.        import android.os.Bundle;  
4.        import android.webkit.WebChromeClient;  
5.        import android.webkit.WebView;  
6.        public
class MainActivity extends Activity {  
7.            /** Called when the activity is first created. */
8.            @Override
9.            public
void onCreate(Bundle savedInstanceState) {  
10.                super.onCreate(savedInstanceState);  
11.                setContentView(R.layout.main);  
12.                WebView mWebView = (WebView)findViewById(R.id.webView01);  
13.                mWebView.getSettings().setJavaScriptEnabled(true);  
14.                mWebView.setWebChromeClient(new WebChromeClient());  
15.                mWebView.loadUrl("file:///android_asset/sample/index.html");  
16.            }  
17.        }