《android编程实践》阅读笔记(一)

来源:互联网 发布:双色球扫描查询软件 编辑:程序博客网 时间:2024/06/05 01:56

《Android编程实践》阅读笔记(一)

组件元素之enabled

  • 官方资料
  • android:enabled
    Whether or not the Android system can instantiate components of the application — “true” if it can, and “false” if not. If the value is “true”, each component’s enabled attribute determines whether that component is enabled or not. If the value is “false”, it overrides the component-specific values; all components are disabled.
  • 是否允许安卓系统初始化应用的组件。
  • 禁用的Activity不会在应用程序启动器中;禁用的Service不会响应startService的调用;禁用的BroadcastReceiver不会监听BroadcastIntent;禁用的ContentProvider不会响应ContentResolver

资源限定符

  • 官方资料
  • You should always externalize application resources such as images and strings from your code, so that you can maintain them independently. You should also provide alternative resources for specific device configurations, by grouping them in specially-named resource directories. At runtime, Android uses the appropriate resource based on the current configuration. For example, you might want to provide a different UI layout depending on the screen size or different strings depending on the language setting.
  • 由于安卓的版本多样,机型的配置,使用者的语言的不同。开发人员管理图片,文字等资源十分困难。好在有资源限定符这个强大的功能,开发人员只需要将合适的资源对号入座,就能够解决这个难题。常见的两个问题是UI(包括layout和图片问题),字符串(多语言)资源的管理

命名顺序参考table2

UI图片大小
这里写图片描述

语言
这里写图片描述

目前对安卓应用架构的理解

  • 安卓应用有五大组件:Activity, Service, BroadcastReceiver, ContentProvider, Application
  • Activity运行在主线程中(也称为UI线程),负责GUI,与用户交互
  • Service也运行在主线程中,同Activity不同的是,它可以在后台运行。IntentService与Service不同,它开启了子线程进行工作。
  • BroadcastReceiver能够获取安卓系统中的广播,用户应用间的信息交流
  • ContentProvider可以用来管理存储数据,如sqlite,如果只是键值对的简单存储用SharedPreference最好
  • Application是个单例,可以在整个应用中的其它组件中获取

效率问题

提高安卓应用效率的官方教程

0 0
原创粉丝点击