1. Generally, a mobile is first and foremost a phone, secondly an SMS and e-mail communicator, thirdly a camera, and fourthly an MP3 player. The applications you write will most likely be in a fi fth category of “useful mobile tools.”
2.To assign a user interface to an Activity, call setContentView from the onCreate method of your
Activity.
3. An Activity without a corresponding activity tag can’t be started.
4. Android applications do not control their own process lifetimes; the Android run
time manages the process of each application
5. Activity Stacks
The state of each Activity is determined by its position on the Activity stack, a last-in–fi rst-out collection of all the currently running Activities. When a new Activity starts, the current foreground screen is moved to the top of the stack. If the user navigates back using the Back button, or the foreground Activity is closed, the next Activity on the stack moves up and becomes active.
Activity States
❑Active
When an Activity is at the top of the stack, it is the visible, focused, foreground activity
that is receiving user input. Android will attempt to keep it alive at all costs, killing Activities
further down the stack as needed, to ensure that it has the resources it needs. When another
Activity becomes active, this one will be paused.
❑ Paused
In some cases, your Activity will be visible but will not have focus; at this point, it’s
paused. This state is reached if a transparent or non-full-screen Activity is active in front of it.
When paused, an Activity is treated as if it were active; however, it doesn’t receive user input
events. In extreme cases, Android will kill a paused Activity to recover resources for the active
Activity. When an Activity becomes totally obscured, it becomes stopped.
❑ Stopped
When an Activity isn’t visible, it “stops.” The Activity will remain in memory retaining
all state and member information; however, it is now a prime candidate for execution when
the system requires memory elsewhere. When an Activity is stopped, it’s important to save data
and the current UI state. Once an Activity has exited or closed, it becomes inactive.
❑ Inactive
After an Activity has been killed, and before it’s been launched, it’s inactive. Inactive
Activities have been removed from the Activity stack and need to be restarted before they can
be displayed and used.
6. it’s important to save all UI state changes and persist all data when an Activity is paused or
stopped. Once an Activity does become active, it should restore those saved values.
7.The following list highlights some of the more familiar toolbox controls:
❑ TextView
A standard read only text label. It supports multiline display, string formatting,
and automatic word wrapping.
❑ EditText
An editable text entry box. It accepts multiline entry and word wrapping.
❑ ListView A View Group that creates and manages a group of Views used to display the items
in a List. The standard ListView displays the string value of an array of objects using a Text
View for each item.
❑ Spinner
Composite control that displays a TextView and an associated ListView that lets you
select an item from a list to display in the textbox. It’s made from a Text View displaying the
current selection, combined with a button that displays a selection dialog when pressed.
❑ Button
Standard push-button
❑ CheckBox
Two-state button represented with a checked or unchecked box
❑ RadioButton
Two-state grouped buttons. Presents the user with a number of binary options
of which only one can be selected at a time.
8. The following list includes some of the more versatile layout classes available:
❑ FrameLayout
The simplest of the Layout Managers, the Frame Layout simply pins each child
view to the top left corner. Adding multiple children stacks each new child on top of the previous,
with each new View obscuring the last.
❑ LinearLayout
A Linear Layout adds each child View in a straight line, either vertically or horizontally.
A vertical layout has one child View per row, while a horizontal layout has a single row
of Views. The Linear Layout Manager allows you to specify a “weight” for each child View that
controls the relative size of each within the available space.
❑ RelativeLayout
Using the Relative Layout, you can defi ne the positions of each of the child
Views relative to each other and the screen boundaries.
❑ TableLayout
The Table Layout lets you lay out Views using a grid of rows and columns. Tables
can span multiple rows and columns, and columns can be set to shrink or grow.
❑ AbsoluteLayout
In an Absolute Layout, each child View’s position is defi ned in absolute coordinates. Using this class, you can guarantee the exact layout of your components, but at a price.
Compared to the previous managers, describing a layout in absolute terms means that your layout
can’t dynamically adjust for different screen resolutions and orientations.
分享到:
相关推荐
在Android开发领域,经典代码例子是开发者学习和提升技能的重要资源。这些例子涵盖了各种关键功能和组件的实现,有助于深入理解Android应用的工作原理。在这个压缩包中,我们可能找到了多个有关Android编程的示例...
在Android开发领域,初学者经常会面临许多挑战,如理解Android应用程序的基本架构、学习XML布局、掌握Java或Kotlin编程语言,以及如何与设备硬件交互等。"Android开发入门60个小案例+源代码"这个资源提供了丰富的...
该组件是基于开源库`Android-wheel`实现的,`Android-wheel`是一个适用于Android的滚轮选择器,它可以创建类似于iOS中PickerView的效果,让用户通过滚动来选取所需的数据。在省市区三级联动中,当用户在一级(省)...
在Android开发中,系统默认的日期和时间选择器虽然实用,但往往无法满足所有场景的需求。因此,开发者经常需要自定义日期选择器来提供更符合应用风格或特定功能的交互体验。这篇内容将深入探讨如何在Android中创建一...
在Android开发中,有时我们需要与远程数据库进行交互,例如SQLServer。这个场景通常是通过Web服务,如WebService来实现。本文将详细介绍如何在Android应用中利用WebService接口连接到SQLServer数据库,实现数据的增...
在Android开发中,串口通信(Serial Port Communication)是一种重要的技术,它允许设备之间通过串行接口进行数据交换。在Android Studio环境下实现串口通信,开发者可以构建与硬件设备交互的应用,例如读取传感器...
在Android开发中,为UI元素添加虚线、圆角和渐变效果是常见的需求,可以提升应用的视觉吸引力。下面将详细讲解如何实现这些效果。 ### 一、虚线(Dashed Line) 在Android中,我们可以使用`Shape Drawable`来创建...
Android应用开发的哲学是把一切都看作是组件。把应用程序组件化的好处是降低模块间的耦合性,同时提高模块的复用性。Android的组件设计思想与传统的组件设计思想最大的区别在于,前者不依赖于进程。也就是说,进程...
----------------------------------- Android 编程基础 1 封面----------------------------------- Android 编程基础 2 开放手机联盟 --Open --Open --Open --Open Handset Handset Handset Handset Alliance ...
在Android开发中,有时我们需要对显示的图片进行特殊处理,比如让图片呈现圆角或完全圆形。本知识点将深入探讨如何在Android应用中完美实现图片的圆角和圆形效果。 首先,我们来看如何实现图片的圆角效果。Android...
Android新编译规则Android.bp文件语法规则详细介绍,条件编译的配置案例。 Android.bp 文件首先是 Android 系统的一种编译配置文件,是用来代替原来的 Android.mk 文件的。在 Android7.0 以前,Android 都是使用 ...
在现代的移动应用开发中,JavaScript与原生平台之间的交互变得越来越常见,特别是在使用Android的WebView组件时。本文将深入探讨如何使用JavaScript调用Android的方法,并传递JSON数据,以实现两者之间的高效通信。 ...
【Android扫雷游戏开发详解】 在移动开发领域,Android Studio是Google推出的官方集成开发环境(IDE),用于构建Android应用程序。本项目"Android扫雷游戏"就是利用Android Studio进行开发的一个实例,旨在帮助初学...
第2篇为应用开发篇,通过实例介绍了Android UI布局、Android人机界面、手机硬件设备的使用、Android本地存储系统、Android中的数据库、多线程设计、Android传感器、Android游戏开发基础、Android与Internet,以及...
【Android 微信语音聊天Demo】是一个典型的移动应用开发示例,主要展示了如何在Android平台上构建类似微信的语音聊天功能。这个Demo包含了按钮状态切换、语音录制、本地存储、回放和加载等一系列关键操作,是Android...
Android SDK离线包合集(Android 4.0-5.0)。不用去Google下载,直接国内下载离线包,各版本文件独立,任意下载。手机流量上传了一部分,好心疼。如不能下载,请告诉我更新地址。 附上简单教程。 这是Android开发所...
在Android开发中,实现图片浏览的全屏缩放效果是一项常见的需求,特别是在社交应用中,如QQ好友动态和微信朋友圈。这种功能不仅需要提供良好的用户体验,还需要考虑性能和内存优化,因为图片通常较大,处理不当可能...
1. **Android SDK**:Android软件开发工具包(SDK)是开发Android应用的基础,包含了开发、调试和发布应用所需的所有工具,如Android Studio IDE、Java Development Kit(JDK)、模拟器以及各种版本的Android平台库...