app主要功能:
1):显示用户以前写下的note;
2):修改note;
3):修改note title;
4):删除note
5)粘贴
app设计:
用户能够交互的界面主要有三个NoteList ,TitleEditor 与 NoteEditor。
NoteList:列出note,根据操作跳转到NoteEditor或TitleEditor。代码为 NoteList.java。
NoteEditor:修改note内容。代码为NoteEditor.java。
TitleEditor:修改note的标题。代码为TitleEditor.java。
代码结构:
NotePad.java定义了一个成员为各种常量的类。在NoteList等其他类中均有使用。NotePadProvider.java似乎是内容提供者的实现,在代码没找到引用,NoteLiveFolder.java
也一样没弄清,先放在一边不管。
AndroidManifest.xml:
app配置信息:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.notepad" > //包,这里跟java代码的package是一样的
<uses-sdk android:minSdkVersion="11" /> //sdk最小版本号
<application android:icon="@drawable/app_notes" //图标
android:label="@string/app_name" //显示app的名字
>
<provider android:name="NotePadProvider" // content provider的信息
android:authorities="com.google.provider.NotePad"
//表示授权给谁,URI 中
content://com.google.provider.NotePad/notes,content://表示URI,由ContentProvider控制,AUTHORITY就是上面的授权给的,"/notes"是路径
android:exported="false"> //该URL能否被其他应用使用
<grant-uri-permission android:pathPattern=".*" /> //可被读取的路径,在这是全都可以读取
</provider>
<activity android:name="NotesList" android:label="@string/title_notes_list">
//活动NoteList
<intent-filter
<action android:name="android.intent.action.MAIN" />
//主要活动
<category android:name="android.intent.category.LAUNCHER" />
//开始时显示这个活动
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
//注册这个活动可进行的动作
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
//可读取上面的URI
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
//什么时候可启动该活动
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
</activity>
。。。。
res/layout/ 存放布局文件
res/values/ 存放字符串等资源
Java代码中 R.id 什么的R代表res目录,上面中@string/title_notes_list指的就是res/values/Strings.xml中title_notes_list的值。
<string name="title_notes_list">Notes</string>