Exersise 1:

把多个字段关联到一个row里面

In the future, remember that the mapping between the from columns and to resources is done using the respective ordering of the two arrays. If we had more columns we wanted to bind, and more Views to bind them in to, we would specify them in order, for example we might use { NotesDbAdapter.KEY_TITLE, NotesDbAdapter.KEY_BODY } and { R.id.text1, R.id.text2 } to bind two fields(字段) into the row (and we would also need to define text2 in the notes_row.xml, for the body text). This is how you can bind multiple fields into a single row (and get a custom row layout as well).

为什么好多函数都需要一个Context参数:

The constructor for NotesDbAdapter takes a Context, which allows it to communicate with aspects of the Android operating system. This is quite common for classes that need to touch the Android system in some way. The Activity class implements the Context class, so usually you will just pass this from your Activity, when needing a Context.

Like many classes in Android, the SimpleCursorAdapter needs a Context in order to do its work, so we pass in this for the context (since subclasses of Activity implement Context).

Exercise 2:

有时候得声明 local variable 来方便我们使用 Dalvik VM里面的variable

Note: We assign the mNotesCursor field to a local variable at the start of the method. This is done as an optimization of the Android code. Accessing a local variable is much more efficient than accessing a field in the Dalvik VM, so by doing this we make only one access to the field, and five accesses to the local variable, making the routine much more efficient. It is recommended that you use this optimization when possible.

startActivityForResult() 和onActivityResult() 经常用于跨进程调用

onActivityResult() is the overridden method which will be called when an Activity returns with a result. (Remember, an Activity will only return a result if launched with startActivityForResult.)

The combination of startActivityForResult() and onActivityResult() 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.

Exercise 3:

onSaveInstanceState() , onPause(), onResume()方法

onSaveInstanceState() is called by Android if the Activity is being stopped and may be killed before it is resumed! This means it should store any state necessary to re-initialize to the same condition when the Activity is restarted. It is the counterpart to the onCreate() method, and in fact the savedInstanceState Bundle passed in to onCreate() is the same Bundle that you construct as outState in the onSaveInstanceState() method.

onPause() and onResume() are also complimentary methods. onPause() is always called when the Activity ends, even if we instigated that (with a finish() call for example). We will use this to save the current note back to the database. Good practice is to release any resources that can be released during an onPause() as well, to take up less resources when in the passive state. onResume() will call our populateFields() method to read the note out of the database again and populate the fields.

转载于:https://www.cnblogs.com/dartagnan/archive/2010/12/24/2003471.html

android doc例程---Notepad Tutorial学习要点!相关推荐

  1. 速学计算机的方法,速记基础:计算机速记方法与学习要点

    双文速记,是根据华语双文(方块字和拉丁字母)原理,在汉语拼音方案基础上采用适合速记要求的拼音方法,在计算机标准键盘上分布普通话的21个辅音.35个元音.4个声调和12个词类字母,将汉语词汇中某些高频单 ...

  2. Android开发技术周报176学习记录

    Android开发技术周报176学习记录 教程 当 OkHttp 遇上 Http 2.0 http://fucknmb.com/2018/04/16/%E5%BD%93OkHttp%E9%81%87% ...

  3. 成为Java高手的25个学习要点

    成为Java高手的25个学习要点 想要精通Java,成为Java高手,需要不断的学习和积累.本文给出了Java学习过程中需要注意的25个学习目标,希望可以给您带来帮助. AD: 2013大数据全球技术 ...

  4. Android开源项目SlidingMenu本学习笔记(两)

    我们已经出台SlidingMenu使用:Android开源项目SlidingMenu本学习笔记(一个),接下来再深入学习下.依据滑出项的Menu切换到相应的页面 文件夹结构: 点击Bluetooth能 ...

  5. Android开发究竟该如何学习,重难点整理

    背景 面是是上海的Android leader岗位,周日一轮面试,自我感觉答的都还不错. 结果收到邮件面试结束了,说什么"你优秀的学识和能力给我们留下了深刻的印象!经过对你综合情况的仔细评估 ...

  6. RIP 注意事项、学习要点及其总结

    RIP 注意事项.学习要点及其总结 转载于:https://blog.51cto.com/danet/364685

  7. android的helloworld工程目录学习

    android的helloworld工程目录学习 Android工程的主要目录有src.gen.Android X.X.bin.res等文件夹. 1.     Src文件夹 Src文件夹包含java源 ...

  8. GTSAM Tutorial学习笔记

    GTSAM Tutorial学习笔记 GTSAM Tutorial学习笔记 1. 基本原理 2. Demo代码 3. LIO-SAM中部分代码分析 3.1 预积分因子图 3.2 关键帧因子图 GTSA ...

  9. mysql的学习要点_MySQL中的联合索引的学习要点总结

    MySQL中的联合索引的学习要点总结 联合索引又叫复合索引.对于复合索引:Mysql从左到右的使用索引中的字段,一个查询可以只使用索引中的一部份,但只能是最左侧部分.例如索引是key index (a ...

最新文章

  1. linux 命令 读phy_CentOS教程(七)- 常用命令使用介绍(上)
  2. python一切皆对象的理解_Python中万物皆对象?的理解
  3. Django model进阶
  4. django中的项目使用mysql中的配置新建用户授予权限
  5. python pillow环境_Python环境Pillow( PIL )图像处理工具使用解析
  6. w我的页面显示服务器错误,vue项目,在本地打开一个页面正常,部署到服务器就会出现 404Not Found 求解?...
  7. Tensorflow2.0数据和部署(二)——基于设备的模型与TensorFlow Lite
  8. Python学习笔记--Python字符串连接方法总结
  9. 深度学习常用软件包和基本环境配置
  10. 插件未购买或已到期,请重新绑定帐号后重试,如操作无效,请将服务器出口IP改为:8XX.XXX.XX.XX
  11. LIBCURL.LIB
  12. 编程序,用getchar函数读人两个字符给c1和c2,然后分别用
  13. 第十九章 存储和使用流数据(BLOBs和CLOBs)
  14. Spark基础(五)SparkSteaming
  15. 【科普】cmd是什么?
  16. el-checkbox的坑(点击全选状态改变了但是不生效)
  17. 高流量的客户服务软件排名
  18. 【从头到脚】前端实现多人视频聊天— WebRTC 实战(多人篇)
  19. [软件人生]读史的三个境界看软件业
  20. Pytest-html生成独立的报告以及Python打印日志

热门文章

  1. mysql的initial_mysql Lost connection to MySQL server at ‘reading initial communication packet
  2. 鸿蒙系统适配机型_小米手机系统软件部总监公布小米各机型安卓P适配计划
  3. 有效的括号Python解法
  4. 全文检索技术_中药图片拍照识别系统,爬虫、深度学习技术android app 源码分享...
  5. 我要回家软件_超4成受访网友认可候补购票:抢票软件难了,还是12306靠谱
  6. php mysql_connect 不支持_php mysql_connect不支持的解决方法
  7. 计算机工程信息学院严翔,严翔校长第六次大师课
  8. 硬核!C语言八大排序算法,附动图和详细代码解释!
  9. HDLBits答案(21)_Verilog有限状态机(8)
  10. LL-verilog语法-generate语句