2010.12.03
@Override:在子类实现父类的方法时,在前一行添加@Override标记是很有好处的:当敲错方法名的时候,编译器会报错。
2010.12.05
AVD
for Android Virtual Device
SDK
for Software Development Kit
API
for Application Programming Interface
GUI
for Graphical User Interface
2010.12.09
一,关于activity:
1,属于android.app.Activity包
2,An
activity is a single, focused thing that the user can do.
活动是一个单独的,能获得焦点的能与用户进行交互(interact)的东西。
3,onCreate(Bundle)
is where you initialize your activity. Most importantly, here you
will usually call setContentView(int)
with a layout resource defining your UI, and using findViewById(int)
to retrieve the widgets in that UI that you need to interact with
programmatically.
其中一个常用(必需?)的方法是onCreate(Bundle),在其中会调用到setContentView(int)链接向res中的layout或者其他资源(xml?)。另外,findViewById(int)用于检索UI中的组件(专业名词为component,也可通称为widget),进行建立触发器(监听器?listener)等操作。
4,To
be of use with Context.startActivity()
,
all activity classes must have a corresponding <activity>
declaration in their package's
AndroidManifest.xml
.建立每个活动之后需要在AndroidManifest.xml中注册才能使用。
5,onCreateOptionsMenu(Menu
menu)
Initialize
the contents of the Activity's standard options
menu.用于建立标准的选项菜单(android上按下menu键进入)public
boolean onOptionsItemSelected
This hook is called whenever an
item in your options menu is selected.用于进一步建立选项菜单的内部选项
二,What
is the differences and conections among Activity, Intent and View?
1,An
activity is a single, focused thing that the user can do.
活动是一个单独的,能获得焦点的能与用户进行交互(interact)的东西。
2,An
intent is an abstract description of an operation to be performed. It
can be used with startActivity
to launch an Activity
.
Intent是一个抽象的描诉(意图做什么事?目前来说我不太理解这个概念),它可以用形如startActivity(new
Intent(this, **))的语句来启动一个新的Activity。
3,View:This
class represents the basic building block for user interface
components. A View occupies a rectangular area on the screen and is
responsible for drawing and event handling. View is the base class
for widgets, which are used to create interactive UI
components (buttons, text fields, etc.)
我暂时的理解是“视图”。View是UI的最基本创建版块,占领一个方形区域用于绘制图形和放置事件的句柄——组件的基本类,常用于建立可交互组件(按钮,文本域)。
4,目前关于这三者的关系,我理解是:application的基本单位应该是Activity——application由许许多多的彼此独立Activity构成。Activity的一个重要特性是它要跟用户产生交互,而交互的关键在于Acitivity里面有许许多多的view,view不仅仅是一个静态的视图,我们可以在View上注册诸如按钮,对话框等交互组件。在Activity中我们经常利用findViewById来查找对应的交互组件(或者说交互组件就是view自身?)来添加listener.那么Intent又是什么?Intent我翻译成意图,目前我只感觉它是一个由一个Activity跳转到另一个Activity的媒介——因为有了这样那样的“意图”,所以我们需要从目前的Activity跳到另外一个才能相应那个“意图”——目前我是这样理解的,不过按文档来说Intent有着更加深厚的意义,那个以后遇上再说吧。
三,label和title的差别?
都是在R下的@string里面的条目,目前来说感觉label是一个短标记后面一般不跟其他东西,title下会跟着其他内容(text,label什么的都可以。)
四,最后要提到的一点,Eclipse的包的自动补全功能Ctrl+Shift+O。(一定要记住阿,相当好用)
2010.12.10
一,magin和padding的差别?
对于一个border(边框)来说,margin是外边距,padding是内边距。
2010.11.12
一,什么是context?
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.
context(语境?)是一个关于应用环境的全局信息的接口,由android系统来负责实现。它可以进行启动Activity和接收intents等操作。
二,关于view的一点细节
不要在view的构造函数中试图使用view的高度和宽度,那是因为那时候Android并不知道视图的大小(当时宽度和高度都默认为0)——Android在布局阶段才会计算宽度和高度——那是在构造函数被调用之后而任何对象被绘制之前。
在视图的宽度和高度已知后,会通知onSizeChanged方法,因而可以在其中引用view的宽度和高度。另一种引用的方法是在诸如onDraw()的方法中用getWidth()与getHeight()获取宽度和高度。
2010.11.14
一,关于Eclipse的一些常用快捷键
ctrl+shift+o
自动补全包,相当好用
ctrl+1
简易提示改成错误的方法
alt+/
自动补全参数名,类名,方法名,巨好用
ctrl+/
给选中范围注释,再按一次为消除注释
ctrl+o
显示类当前继承结构
ctrl+shift+f
给选中内容进行自动排版。
二,实现[Android开发视频教学].01_05_Activity和Intent
的代码时遇到的错误:
(1)错误:R.id.one是一个EditText,我企图直接用String
one = getText(R.id.one).toString()来直接把它的值赋予给one。结果是弹出异常。
改正办法:正确代码如下:EditText
textOne = (EditText)findViewById(R.id.one);String one =
textOne.getText().toString();
即先建立一个名为textOne的EditText,然后用getText()方法得到它的内容。
(2)错误:企图直接用setText(answer)方法来直接输入answer(ansser是个int变量)。
改正办法:代码改写成setText(answer
+
“”);即可(根据Java语法,int+String类型自动转换成String类型,补充一句是setText()里面的内容只能是String类型的东西)
2010.11.15
一,关于Bundle:
A
mapping from String values to various Parcelable types.
一个从字符值到各种可打包类型的映射。
(目前就在onCreate(Bundle
savedInstanceState)看到过,理解成一捆数据么?)
二,this和super指针用法:
this概述:在生成一个对象的时候,系统会自动生成一个指向对象的this指针,所以this指针是不会指向静态类的。
用法:(1)在方法中存在该对象的同名实例变量,需要用“this.实例变量名”来引用实例变量。
(2)在方法中需要应用到对象自身的时候,用
”类名.this“来进行引用。
(3)可以在构造函数中直接用“this(参数名)”
来调用自身构造函数,有时候可以简化代码。
super概述:在继承关系中,super指向子类的父类。
用法:(1)在子类中引用父类的同名实例变量时,用“super.实例变量名”引用父类的变量。
(2)在子类的构造函数中用super.构造函数名()调用父类的构造函数。(只能放在构造函数的第一行)
(3)在子类中引用父类的同名方法时,用“super.方法名(参数名)”引用父类的方法。
三,Eclipse中又两个个好用的快捷键:
F3:快速定位当前选中的自定义方法,自定义变量名的原出处。
F4:快速展开选中类的继承层次。
posted on 2010-12-18 14:45
level0 阅读(924)
评论(0) 编辑 收藏 所属分类:
android日志