Eclipse Mobile Mousw Manual de usuario Pagina 17

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 35
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 16
The sample application contains a single activity and a single view. The application
contains a file named main.xml that represents the visual aspects of the primary UI
of the activity. Note that there is no reference in the main.xml where the layout is
used. This means it may be used in more than one activity, if desired. Listing 5
contains the content of the layout file.
Listing 5. Layout file
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, SaySomething"
/>
</LinearLayout>
This is the most simplistic of layouts. There is a single linear layout, which is oriented
as a vertical layout, meaning all contained elements are in a single column. There is
a single TextView element, which can be likened to a label in other development
environments. A TextView represents static text that is not editable.
Note that each view element (layout and TextView in this example) have
attributes in the Android name space. Some attributes are common to all views —
the android:layout_width and android:layout_height attributes, for
example. The values available for these attributes are:
Fill Parent
This extends the view element to take the maximum space available. This can
also be thought of as meaning "stretch."
Wrap Content
This value tells Android to paint the elements one after the next without
stretching.
During the build process, all resources are compiled. One of the products of that
process is the R.java file, which represents the resources to the remainder of the
application. The R.java file is discussed next.
R.java
The R.java file is created upon build automatically, so be sure to not modify it by
hand as all changes will be lost. Listing 6 contains the R.java file for the sample
application.
ibm.com/developerWorks developerWorks®
Develop Android applications with Eclipse
© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 17 of 35
Vista de pagina 16
1 2 ... 12 13 14 15 16 17 18 19 20 21 22 ... 34 35

Comentarios a estos manuales

Sin comentarios