Calvin's Tech Space

成于坚忍,毁于浮躁

   :: 首页 :: 联系 :: 聚合  :: 管理

<?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解析器后面的是一个资源引用,+意味着如果没有这个资源就创建一个
  • list和empty ID是Android平台提供的,因此要加上android: 前缀
  • layout文件下的每一个xml文件在R.java中都有一个class对应,其中的每一个资源在R.java中都有相应的入口,以便在应用程序中方便的引用
  •  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 阅读(231) 评论(0)  编辑  收藏 所属分类: Android

只有注册用户登录后才能发表评论。


网站导航: