An App a day——Notepad Tutorial
来源:互联网 发布:idea调试java web项目 编辑:程序博客网 时间:2024/04/27 21:19
http://developer.android.com/training/notepad/index.html
Notepad Exercise 1
To learn
- The basics of ListActivities and creating and handling menu options.
- How to use a SQLite database to store the notes.
- How to bind data from a database cursor into a ListView using a SimpleCursorAdapter.
- The basics of screen layouts, including how to lay out a list view, how you can add items to the activity menu, and how the activity handles those menu selections.
learned
- NotesDbAdapter, simple notes database access helper class.Defines the basic CRUD operations for the notepad example, and gives the ability to list all note as well as retrieve or modify a specific note.
- CRUD是指在做计算处理时的增加(Create)、读取(Read)(重新得到数据)、更新(Update)和删除(Delete)几个单词的首字母简写。主要被用在描述软件系统中数据库或者持久层的基本操作功能。
- android.database.sqlite.SQLiteDatabase
Exposes methods to manage a SQLite database.
SQLiteDatabase has methods to create, delete, execute SQL commands, and perform other common database management tasks.
- android.content.Context
- Interface to global information about an application environment.This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.
- android.database.Cursor
This interface provides random read-write access to the result set returned by a database query.
Cursor implementations are not required to be synchronized so code using a Cursor from multiple threads should perform its own synchronization when using the Cursor.
- Note: A Cursor is returned rather than a collection of rows. This allows Android to use resource efficiently -- instead of putting lots of data straight into memory, the cursor will retrieve and release data as it is needed, which is much more efficient for tables with lots of rows.
- android.content.ContentValues
This class is used to store a set of values that the ContentResolver can process.
- android.content.ContentResolver
This class provides applications access to the content model.
- XML is a text-base markup language.
The XML namespace of Android should always be defined in the top level component or layout in the XML so that android: tags can be used through the rest of the file:
xmlns:android="http://schemas.android.com/apk/res/android"
- Field这个词在Java中对应的中文翻译是“域”,很形象吧,其实就是类的成员,field是sun公司的专业用语
Field包括:
1.instance variable(实例变量)
2.class variable(类变量,static修饰)
3.constant(常量,final修饰)
field的意思是“字段”,这里可以理解成变量。
field的解释:
class A{
private int a; //private field私有域
protected double b; //protected field保护域
public String c; //public field公共域
A d; //default access field默认访问域
public static Object e; //public static field公共静态域
.....
}
- 在LogCat里设置Filter,by Application Name,可以看到当前App的Log
- <TextView android:id="@android:id/empty"
- The list and empty IDs are provided for us by the Android platform, so, we must prefix the id with android: (e.g., @android:id/list).
- The View with the empty id is used automatically when the ListAdapter has no data for the ListView. The ListAdapter knows to look for this name by default. Alternatively, you could change the default empty view by using setEmptyView(View) on the ListView.
- More broadly, 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).
- 注意+号和android:前缀,因为这里用的是Android platform的ID,而不是新建一个。
Notepad Exercise 2
To learn:
- Constructing a new Activity and adding it to the Android manifest
- Invoking another Activity asynchronously using startActivityForResult()
- Passing data between Activity in Bundle objects
- How to use a more advanced screen layout
- How to create a context menu
learned:
- 更改为自己的Project:
Project Name
Package Name
Java Name
Run Configuration
API
- Import Existing Android Code Into Workspace的时候,如果Project目录就在Workspace里,则需要勾选Copy projects into workspace,否则报错
- The m denotes a member field and is part of the Android coding style standards.
- When you register a View to a context menu, the context menu is revealed by performing a "long-click" on the UI component
- Accessing a local variable is much more efficient than accessing a field in the Dalvik VM
- The combination of
startActivityForResult()
andonActivityResult()
can be thought of as an asynchronous RPC (remote procedure call) and forms the recommended way for an Activity to invoke another and share services. - Listeners are a common idiom in Java development, particularly for user interfaces.In the
Superclass:
field, enterandroid.app.Activity
(you can also just type Activity and hit Ctrl-Space on Windows and Linux or Cmd-Space on the Mac, to invoke code assist and find the right package and class). - Listeners are a common idiom in Java development, particularly for user interfaces.
Notepad Exercise 3
To learn:
- Life-cycle events and how your application can use them
- Techniques for maintaining application state
- In
NoteEdit
, we need to check the savedInstanceState for themRowId
, in case the note editing contains a saved state in the Bundle, which we should recover (this would happen if our Activity lost focus and then restarted).
0 0
- An App a day——Notepad Tutorial
- An App a day——NFC小助手
- An App a day——RFID DEMO
- Android Tutorial: How To Post Data From An Android App To a Website
- Web Analytics: An Hour a Day
- Search Engine Optimization: An Hour a Day
- Social Media Marketing: An Hour a Day
- [An AC a day]1001_HIT_ACM
- [An AC a day]1002_HIT_ACM
- [An AC a day]1003_HIT_ACM
- [An AC a day]1004_HIT_ACM
- [An AC a day]Daily Practice_BIT
- [An AC a day]1088_POJ_ACM
- [An AC a day]2084_HDU_ACM
- [An AC a day]1050_POJ_ACM
- [An AC a day]3624_POJ_ACM
- [An AC a day]1160_HDU_ACM
- [An AC a day]1160_HDU_ACM
- OracleOraDb10g_home1TNSListener启动后自动停止的问题
- java中的context
- Redis内存存储结构分析
- C#解析json以及简单的介绍
- python版的短信轰炸机smsbomb----------上篇(post)
- An App a day——Notepad Tutorial
- Eclipse get/set方法自动加上字段注释
- 老大的烦恼
- ubuntu连接路由器无线网络,却不能上网
- jquery水平滑动图片切换特效
- MILTrack学习3--自适应外观模型
- 一个在试用期最后半个月离开Rigol的Loser,给后来者的建议
- oracle调优 性能与安全的权衡
- 为你,最后的执笔