<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 59, comments - 244, trackbacks - 0, articles - 0
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    開始android的HelloWorld

    Posted on 2011-02-23 00:44 penngo 閱讀(2938) 評論(2)  編輯  收藏 所屬分類: android
    android很火,也來學習下,上段時間上它官網(官網的訪問不了,只能訪問http://androidappdocs-staging.appspot.com/sdk/index.html)把android-sdk_r09-windows.zip下了回來,本來以為下了這個就能開始寫helloWorld,點知里面根本沒有開發的SDK和相關的開發工具,通過這地址https://dl-ssl.google.com/android/eclipse/給eclipse安裝ADT插件。安裝完ADT,利用SDK Manager.exe開始漫長的SDK下載,足足下了兩個晚上才下完。按著它官方的Tutorials,等了兩個晚上終于可以開始HelloWorld。
    HelloAndroid.java
    import android.app.Activity;
    import android.os.Bundle;

    public class HelloAndroid extends Activity {
        
    /** Called when the activity is first created. */
        @Override
        
    public void onCreate(Bundle savedInstanceState) {
            
    super.onCreate(savedInstanceState); 
            setContentView(R.layout.main); 
        }

    }

    main.xml
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:orientation
    ="vertical" 
        android:layout_width
    ="fill_parent" 
        android:layout_height
    ="fill_parent"> 
     
      
    <LinearLayout 
          
    android:orientation="horizontal" 
          android:layout_width
    ="fill_parent" 
          android:layout_height
    ="fill_parent" 
          android:layout_weight
    ="1"> 
          
    <TextView 
              
    android:text="red" 
              android:gravity
    ="center_horizontal" 
              android:background
    ="#aa0000" 
              android:layout_width
    ="wrap_content" 
              android:layout_height
    ="fill_parent" 
              android:layout_weight
    ="1"/> 
          
    <TextView 
              
    android:text="green" 
              android:gravity
    ="center_horizontal" 
              android:background
    ="#00aa00" 
              android:layout_width
    ="wrap_content" 
              android:layout_height
    ="fill_parent" 
              android:layout_weight
    ="1"/> 
          
    <TextView 
              
    android:text="blue" 
              android:gravity
    ="center_horizontal" 
              android:background
    ="#0000aa" 
              android:layout_width
    ="wrap_content" 
              android:layout_height
    ="fill_parent" 
              android:layout_weight
    ="1"/> 
          
    <TextView 
              
    android:text="yellow" 
              android:gravity
    ="center_horizontal" 
              android:background
    ="#aaaa00" 
              android:layout_width
    ="wrap_content" 
              android:layout_height
    ="fill_parent" 
              android:layout_weight
    ="1"/> 
      
    </LinearLayout> 
             
      
    <LinearLayout 
        
    android:orientation="vertical" 
        android:layout_width
    ="fill_parent" 
        android:layout_height
    ="fill_parent" 
        android:layout_weight
    ="1"> 
        
    <TextView 
            
    android:text="row one" 
            android:textSize
    ="15pt" 
            android:layout_width
    ="fill_parent" 
            android:layout_height
    ="wrap_content" 
            android:layout_weight
    ="1"/> 
        
    <TextView 
            
    android:text="row two" 
            android:textSize
    ="15pt" 
            android:layout_width
    ="fill_parent" 
            android:layout_height
    ="wrap_content" 
            android:layout_weight
    ="1"/> 
        
    <TextView 
            
    android:text="row three" 
            android:textSize
    ="15pt" 
            android:layout_width
    ="fill_parent" 
            android:layout_height
    ="wrap_content" 
            android:layout_weight
    ="1"/> 
        
    <TextView 
            
    android:text="row four" 
            android:textSize
    ="15pt" 
            android:layout_width
    ="fill_parent" 
            android:layout_height
    ="wrap_content" 
            android:layout_weight
    ="1"/> 
      
    </LinearLayout> 
    </LinearLayout>


    下面是個人對這兩個文件的小小見解:

    main.xml用來描述程序的用戶界面,感覺通過xml來描述頁面布局這方式很流行,Silverlight使用XAML描述頁面布局,QT使用QML描述界面,看來XML UI描述語言在桌面應用將會更廣泛,在PB、Delphi、VC、VB年代,根據還未聽過有XML UI,不過HTML在BS的應用倒是讓所有人如雷貫耳,哈哈。android的XML UI與QT相比,還弱了點,因為QML支持js,不知哈時候,android能支持js,不過寫這篇文章的前一天剛好看到Qt for Android (Alpha) 發布新聞,就是不知java版的SDK哈時候能做到這一步。
    HelloAndroid繼承Activity,Activity具有自己的生命周期,也就是按一定的事件流程運行,從開始到銷毀的事件流程為
    void onCreate(Bundle savedInstanceState)
    void onStart()
    void onRestart()
    void onResume()
    void onPause()
    void onStop()
    void onDestroy()
    這讓我覺得它和applet非常相似,
    applet生命周期
    void init()
    void start()
    void stop()
    void destroy()

    目前android還不熟悉,暫寫這么多記錄下來,有空再繼續學習。


    評論

    # re: 開始android的HelloWorld  回復  更多評論   

    2011-02-23 15:59 by 步步為營
    Android最近好火呀,我也在學,呵呵

    # re: 開始android的HelloWorld  回復  更多評論   

    2011-02-23 23:07 by penngo
    呵呵,一起學.
    主站蜘蛛池模板: 国产亚洲精品精品精品| 亚洲午夜无码久久久久软件 | 亚洲网站视频在线观看| 人人玩人人添人人澡免费| 在线亚洲午夜理论AV大片| 七次郎成人免费线路视频| 国产精品亚洲mnbav网站 | 最近免费中文字幕MV在线视频3| 久久久久亚洲AV成人网人人网站| 一级毛片a女人刺激视频免费| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 亚洲第一黄色网址| 国产精品1024在线永久免费 | 特级一级毛片免费看| 精品国产香蕉伊思人在线在线亚洲一区二区| 污污污视频在线免费观看| 亚洲综合色成在线播放| 国产自国产自愉自愉免费24区| 亚洲欧洲免费视频| 在线天堂免费观看.WWW| 久久精品国产亚洲av天美18| 亚洲免费在线观看| 男人的天堂网免费网站| ass亚洲**毛茸茸pics| 国产又大又长又粗又硬的免费视频 | 久久大香香蕉国产免费网站| 亚洲精品不卡视频| 日韩免费福利视频| 精品国产一区二区三区免费| 亚洲宅男天堂a在线| 国产又大又黑又粗免费视频 | 久久久久国产精品免费免费搜索| 国产成人精品久久亚洲高清不卡 | 立即播放免费毛片一级| 久久亚洲精品视频| 猫咪社区免费资源在线观看 | 黄页网址大全免费观看12网站| 国产亚洲人成网站观看| 性色av无码免费一区二区三区| 日韩毛片一区视频免费| 亚洲无人区视频大全|