今天第一天学习android,通过mars的视频的,总体上学起来感觉还不错,还是能够快的接受mars老师的思想的。
今天主要学习了android的工程的建立,各个目录的功能。
主要的技术上的东西学了activity:
建立activity,主要包括几步:创建继承于Activity类的类,覆写oncreate()方法;在AndroidMainfest.xml中注册;建立相应的在layout中布局文件.xml;
多个activity通过intent交互,对于Intent有Compenent Name,Action, Data和Extra(键值);
几个比较常用的控件:EditText、TextView、Button和Menu,其中Menu的添加相对于其他三个由所有不同,通过在Activity中覆写父类的OnCreateOptionMenu()
对于事件的响应采用监听器的方式,使用匿名类;
Activity的生命周期,主要是对7个函数的了解
onCreate():Called when the activity is first created;
onStart():Called when the activity is becoming visible to the user;
onResume():Called when the activity will start interacting with the user(也即获得焦点时);
onPause():Called when the system is about to start resuming a previous activity;(失去焦点时)
onStop():Called when the activity is no longer visible to the user;
onRestart():Called after your activity has been stopped, prior to it being started again.;
onDestroy():The final call you receive before your activity is destroyed. This can happen either because the activity is finishing (someone called
finish()
on it, or because the system is temporarily destroying this instance of the activity to save space;
例子注意对话框的区别:对话框的弹出就是让之前的Activity失去焦点,但是是可见的,就执行到OnPause()这一步。