Calvin's Tech Space

          成于堅(jiān)忍,毀于浮躁

             :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理

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

            <ListView android:id="@android:id/list"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"/>
            <TextView android:id="@android:id/empty"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="@string/no_notes"/>

          <TextView android:id="@+id/text1"
              xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"/>
          </LinearLayout>

          • @告訴XML解析器后面的是一個(gè)資源引用,+意味著如果沒(méi)有這個(gè)資源就創(chuàng)建一個(gè)
          • list和empty ID是Android平臺(tái)提供的,因此要加上android: 前綴
          • layout文件下的每一個(gè)xml文件在R.java中都有一個(gè)class對(duì)應(yīng),其中的每一個(gè)資源在R.java中都有相應(yīng)的入口,以便在應(yīng)用程序中方便的引用
          •  The android.R class is a set of predefined resources provided for you by the platform, while your project's R class is the set of resources your project has defined. Resources found in the android.R resource class can be used in the XML files by using the android: name space prefix (as we see here).
          • Most Activity classes will have a layout associated with them. The layout will be the "face" of the Activity to the user. In this case our layout will take over the whole screen and provide a list of notes.Full screen layouts are not the only option for an Activity however. You might also want to use a floating layout (for example, a dialog or alert), or perhaps you don't need a layout at all (the Activity will be invisible to the user unless you specify some kind of layout for it to use).

          • This example uses a SimpleCursorAdapter to bind a database Cursor into a ListView, and this is a common way to use a ListAdapter. Other options exist like ArrayAdapter which can be used to take a List or Array of in-memory data and bind it in to a list as well.

          http://www.chinaup.org/docs/intro/tutorial-ex1.html

          posted on 2009-09-02 09:12 calvin 閱讀(234) 評(píng)論(0)  編輯  收藏 所屬分類: Android
          主站蜘蛛池模板: 曲阳县| 会昌县| 邹城市| 海阳市| 东至县| 太原市| 钦州市| 方山县| 宁波市| 郸城县| 湘潭市| 榕江县| 兰州市| 图片| 通州区| 临漳县| 多伦县| 鄂托克前旗| 道孚县| 满洲里市| 木兰县| 临漳县| 师宗县| 东安县| 图们市| 库尔勒市| 盐山县| 长顺县| 阜新市| 县级市| 怀安县| 安陆市| 黄大仙区| 长岛县| 临夏县| 台安县| 鄱阳县| 邵武市| 汕头市| 南宫市| 宁夏|