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. 【学亮IT手记】SpringMVC增删改查+map数据返回Controller层代码示例
  2. observer pattern
  3. 支付宝上线新功能:家长们放心了!
  4. 10 个 Python 初学者必知编码小技巧
  5. 如何使用Mac DVDRipper Pro在mac上备份包括菜单和附加功能在内的完整的DVD
  6. Linux小知识收集(不断更新)
  7. 计算机开机界面图片怎么修改,电脑win7系统怎么修改开机画面的方法
  8. JS判断不同的浏览器和版本,提示浏览器版本过低,兼容IE8到IE11
  9. 不离不弃共赴鸿蒙是什么歌,很早听过一首粤语歌,歌词好像是往往世界这么大 又可以遇到你 蛮经典的一首歌 求解答...
  10. HSV颜色空间中颜色(红、黄、绿、 青、蓝、紫、 粉红、 砖红、 品红)对应的灰度范围
  11. 银联携手酷客多协助百万商家上线小程序
  12. 【1】CRM_SSH环境搭建
  13. 【SaltStack官方版】—— returners——返回器
  14. oracle从mysql抓数据_关于oracle数据库读取数据的三种方式
  15. 离谱,还有这种自暴自弃的翻译?
  16. Mac键盘不起作用?苹果电脑键盘失灵解决教程
  17. cas登录成功什么意思_单点登录系统和CAS的简介
  18. Jackson简单用法
  19. 是时候该和Picasa说再见了
  20. 三种EXCEL去重统计方法

热门文章

  1. 三坐标测量圆直径_RationalDMIS 7.1 如何准确测量圆/圆弧直径
  2. wxpython 按钮跳notebook_按钮按下wxpython刷新窗口
  3. python随机抽样numpy_python numpy之np.random的随机数函数使用介绍
  4. eclipse配置本地连接 hadoop
  5. java开发学不会_JAVA学不会,快期末了,怎么办?
  6. GB2312 UTF8 UCS2汉字编码对应表
  7. 北航和哈佛研发软体机器人,抓住各类物体!
  8. python中、变量指向的对象可以发生变化吗_python中的引用传递,可变对象,不可变对象,list注意点...
  9. html asp textbox,ASP.NET中 TextBox 文本输入框控件的使用方法
  10. php文件夹重命名,php文件下载并重命名