- Activity是一个User Interface Program。
- Intent用于画面跳转。由Action和Data组成。
- Bundle在Activity间传递数据。
/* new 一个Intent对象,并指定class */
Intent intent = new Intent();
intent.setClass(Ex10_UI.this, BMIActivity.class);
/* new 一个Bundle对象,并将要传递的数据传入*/
Bundle bundle = new Bundle();
bundle.putDouble("height", height);
bundle.putString("sex", sex);
/* 将Bundle对象assign给Intent*/
intent.putExtras(bundle);
/* 调用ActivityEX03_10_1 */
startActivity(intent);
Bundlebunde = this.getIntent().getExtras();
/* 取得Bundle对象中的数据*/
String sex = bunde.getString("sex");
double height = bunde.getDouble("height");
重载onActivityResult(intrequestCode, int resultCode, Intent data) 来在源请求Activity中等待Intent返回应答结果。
- Log.v设置标签来跟踪程序。
- Activity状态 onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy(), onRestart()
onPause:失去焦点
onDestroy:完全隐藏
- Service:startService可以使Service独立于进程不死,bindService跟进程同死。
- UI 编程
如果定义style,color等,需在res/values里定义xml,键值会自动辨识到R文件里
DisplayMetrics类取得画面宽高
标题栏隐藏:在Activity.setCurrentView()之前调用requestWindowFeature(Window.FEATURE_NO_TITLE)
状态栏隐藏:在Activity.setCurrentView()之前调用
requestWindowFeature(Window.FEATURE_NO_TITLE);
//定义全屏参数
int flag=WindowManager.LayoutParams.FLAG_FULLSCREEN;
//获得窗口对象
Window myWindow=this.getWindow();
//设置Flag标识
myWindow.setFlags(flag,flag);
获取控件资源用press=(Button)findViewById(R.id.Click_Button);
给Button添加事件监听器
press.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}});
页面转换
setContentView(R.layout.otherview); - ADB(Android Debug Bridge)
adb install app.apk
adb shell
adb forward tcp:6100 tcp:7100
adb push "" /data
adb pull
adb devices
adb shell -> sqlite3