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.
分享到:
相关推荐
通过这59个实例,开发者可以逐步学习并掌握STM32F407的寄存器编程技巧,理解每个功能模块的工作原理,从而在实际项目中游刃有余。无论是初学者还是经验丰富的工程师,都能从中受益,提升对STM32F407微控制器的掌控...
STM32F429是意法半导体...总的来说,"标准例程-HAL库版本.zip"为STM32F429的开发者提供了一个宝贵的资源库,通过深入学习和实践这些例程,可以快速提升STM32的开发能力,更好地驾驭这款强大的微控制器。
STM32F103标准库函数例程是学习和应用STM32微控制器不可或缺的一部分。这个压缩包“STM32F103标准例程-库函数版本.rar”提供了基于STM32F103的开发实例,适用于初学者在keil集成开发环境中进行实践。STM32F103是一款...
msp430f5438--例程--综合应用.rar msp430f5438--例程--综合应用.rar msp430f5438--例程--综合应用.rar msp430f5438--例程--综合应用.rar msp430f5438--例程--综合应用.rar
在"易语言--串口例程--初学者学习硬件控制利器"这个主题中,我们主要探讨的是如何利用易语言来实现对硬件设备的控制,特别是通过串行通信接口(串口)进行数据传输。 串口,也称为COM口,是计算机硬件中的一种标准...
发动机控制例程-初学者入门例程.zip西门子PLC编程实例程序源码下载发动机控制例程-初学者入门例程.zip西门子PLC编程实例程序源码下载发动机控制例程-初学者入门例程.zip西门子PLC编程实例程序源码下载发动机控制例程...
这个压缩包“stm32f407标准例程-库函数版本.zip”包含了一系列基于STM32F407的库函数示例代码,对于学习和开发STM32F407的项目非常有帮助。 STM32F407微控制器基于ARM Cortex-M4内核,具备浮点运算单元(FPU),...
msp430f5438--例程--渐进提高.rar msp430f5438--例程--渐进提高.rar msp430f5438--例程--渐进提高.rar msp430f5438--例程--渐进提高.rar msp430f5438--例程--渐进提高.rar
msp430f5438--例程--基础入门.rar msp430f5438--例程--基础入门.rar msp430f5438--例程--基础入门.rar msp430f5438--例程--基础入门.rar
STM32F103C8T6例程-DEMOSTM32F103C8T6例程-DEMOSTM32F103C8T6例程-DEMOSTM32F103C8T6例程-DEMOSTM32F103C8T6例程-DEMOSTM32F103C8T6例程-DEMOSTM32F103C8T6例程-DEMOSTM32F103C8T6例程-DEMOSTM32F103C8T6例程-DEMO
西门子PLC例程-logo!的一些例子
标准例程-V3.5库函数版本\keilkill.bat 标准例程-V3.5库函数版本\实验0 Template工程模板\CORE\core_cm3.c 标准例程-V3.5库函数版本\实验0 Template工程模板\CORE\core_cm3.h 标准例程-V3.5库函数版本\实验0 ...
原来的描述:MAX30102心率血氧显示例程,keil-MDK,C语言,裸机代码,包含计算心率...网上的PA2/PA3引脚为串口传输的都是美信官方例程!用C++写的,还带个mbed的操作系统。 移植不易,如果对你有帮助,记得给个好评!
iTOP-4412-Android-485测试例程-精英板.zip是一个与RS485通信相关的软件包,适用于iTOP-4412开发板,并且是基于Android系统的。在本文中,我们将深入探讨RS485通信协议、iTOP-4412开发板以及如何在Android系统上实现...
CC2540 CC2541蓝牙开发板实验例程软件工程源码20个合集: 41软件例程-.Mpu6050六轴传感器 CC2540 CC2541软件例程-.PIR人体红外传感器 CC2540 CC2541软件例程-.外部中断-按键检测 CC2540 CC2541软件例程-.系统睡眠...
例程1-Hello World! 例程2-LED 闪烁 例程3-PWM调光 例程4-广告灯 例程5-交通灯 例程6-按键控制 例程7-抢答器 例程8-蜂鸣器 例程9-模拟值 例程10-光控声音 例程11-感光灯 例程12-温度传感 例程13-倾斜开关 例程14-...
本项目“基于西门子PLC例程---变频节能供水”旨在帮助学习者理解如何利用西门子PLC实现高效、经济的供水系统。 首先,我们要了解变频节能供水的基本原理。传统的供水系统通常采用恒速泵进行工作,而无论实际需求...
【作品名称】:基于西门子 PLC 例程--- 恒压供水-1 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。
【作品名称】:基于LG PLC例程例程-- LG XGB PLC的程式,用於线路板设备 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。
【作品名称】:基于西门子 PLC 例程--- 恒压供水 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。