http://ask.lurencun.com

海大知道

Android菜鸟日记

Android应用程序主要由3部分组成:应用程序描述文件[xml],各种资源的集合[res],以及应用程序的源代码。

j2ee开发与android发开有高度的类似

j2ee用标记语言构建viewandroid也是,但Android用的标记语言xml这种标记语言更好,无需硬编码应用程序的view,可以通过标记来修改应用程序的外观。

Android不允许在res文件夹中的文件夹中创建文件夹

即不支持res/a/b如此。

只支持res/a

<?xmlversion="1.0"encoding="utf-8"?>

<manifestxmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.android.notepad"

>

根包名(package)的定义是<mainfest>元素的一个特性[特性必须有]

每个activity都有一个name特性。Name名即为类名[每个activity对应一个类此类完整包名为mainfestppackage.name这里的name对应的是根包名目录下的类]

确定了入口的activity程序会调用onCreate()方法

<applicationandroid:icon="@drawable/app_notes"

android:label="@string/app_name"

>

<providerandroid:name="NotePadProvider"

android:authorities="com.google.provider.NotePad"

/>

<activityandroid:name="NotesList"android:label="@string/title_notes_list">

<intent-filter>

<actionandroid:name="android.intent.action.MAIN"/>

<categoryandroid:name="android.intent.category.LAUNCHER"/>

</intent-filter>

<intent-filter>

<actionandroid:name="android.intent.action.VIEW"/>

<actionandroid:name="android.intent.action.EDIT"/>

<actionandroid:name="android.intent.action.PICK"/>

<categoryandroid:name="android.intent.category.DEFAULT"/>

<dataandroid:mimeType="vnd.android.cursor.dir/vnd.google.note"/>

</intent-filter>

<intent-filter>

<actionandroid:name="android.intent.action.GET_CONTENT"/>

<categoryandroid:name="android.intent.category.DEFAULT"/>

<dataandroid:mimeType="vnd.android.cursor.item/vnd.google.note"/>

</intent-filter>

</activity>

<activityandroid:name="NoteEditor"

android:theme="@android:style/Theme.Light"

android:label="@string/title_note"

android:screenOrientation="sensor"

android:configChanges="keyboardHidden|orientation"

>

<!--Thisfiltersaysthatwecanvieworeditthedataof

asinglenote-->

<intent-filterandroid:label="@string/resolve_edit">

Intent通常定义了某种工作的“意图”

<actionandroid:name="android.intent.action.VIEW"/>

<actionandroid:name="android.intent.action.EDIT"/>

<actionandroid:name="com.android.notepad.action.EDIT_NOTE"/>

<categoryandroid:name="android.intent.category.DEFAULT"/>

<dataandroid:mimeType="vnd.android.cursor.item/vnd.google.note"/>

</intent-filter>

<!--Thisfiltersaysthatwecancreateanewnoteinside

ofadirectoryofnotes.-->

<intent-filter>

<actionandroid:name="android.intent.action.INSERT"/>

<categoryandroid:name="android.intent.category.DEFAULT"/>

<dataandroid:mimeType="vnd.android.cursor.dir/vnd.google.note"/>

</intent-filter>

</activity>

<activityandroid:name="TitleEditor"

android:label="@string/title_edit_title"

android:theme="@android:style/Theme.Dialog"

android:windowSoftInputMode="stateVisible">

<!--Thisactivityimplementsanalternativeactionthatcanbe

performedonnotes:editingtheirtitle.Itcanbeusedas

adefaultoperationiftheuserinvokesthisaction,andis

availableasanalternativeactionforanynotedata.-->

<intent-filterandroid:label="@string/resolve_title">

<!--Thisistheactionweperform.Itisacustomactionwe

defineforourapplication,notagenericVIEWorEDIT

actionsincewearenotageneralnoteviewer/editor.-->

<actionandroid:name="com.android.notepad.action.EDIT_TITLE"/>

<!--DEFAULT:executeifbeingdirectlyinvoked.-->

<categoryandroid:name="android.intent.category.DEFAULT"/>

<!--ALTERNATIVE:showasanalternativeactionwhentheuseris

workingwiththistypeofdata.-->

<categoryandroid:name="android.intent.category.ALTERNATIVE"/>

<!--SELECTED_ALTERNATIVE:showasanalternativeactiontheuser

canperformwhenselectingthistypeofdata.-->

<categoryandroid:name="android.intent.category.SELECTED_ALTERNATIVE"/>

<!--Thisisthedatatypeweoperateon.-->

<dataandroid:mimeType="vnd.android.cursor.item/vnd.google.note"/>

</intent-filter>

</activity>

<activityandroid:name="NotesLiveFolder"android:label="@string/live_folder_name"

android:icon="@drawable/live_folder_notes">

<intent-filter>

<actionandroid:name="android.intent.action.CREATE_LIVE_FOLDER"/>

<categoryandroid:name="android.intent.category.DEFAULT"/>

</intent-filter>

</activity>

</application>

<uses-sdkandroid:targetSdkVersion="4"android:minSdkVersion="3"/>

</manifest>