Android开发学习笔记

来源:互联网 发布:mui.js文档 编辑:程序博客网 时间:2024/05/21 09:25

  1. Activity是一个User Interface Program。

  2. Intent用于画面跳转。由Action和Data组成。

  3. 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对象assignIntent*/
    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返回应答结果。

  4. Log.v设置标签来跟踪程序。

  5. Activity状态 onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy(), onRestart()
    onPause:失去焦点
    onDestroy:完全隐藏    

                 
  6. Service:startService可以使Service独立于进程不死,bindService跟进程同死。

  7. 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);
  8. 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



0 0
原创粉丝点击