您的位置:首页 > 移动开发 > Android开发

第一个android程序:helloworld

2011-07-24 11:54 387 查看
平台前向兼容软件: 指老平台下生成的程序在新平台上也能运行。等价于软件后向兼容平台。
根据coolszy的操作过程可以正确完成helloworld程序,感谢coolszy的视频。
android模拟器每次运行都会临时生成几个tmp临时文件,时间长了,可能占用几G的空间,目录为
【win7用户】C:\Users\Administrator\AppData\Local\Temp\AndroidEmulator文件夹下
或者【xp用户】C:\Documents and settings\"用户名"\Local settings\Temp\AndroidEmulator文件夹下。
android核心开发包
android.util  Provides common utility methods such as date/time manipulation, base64 encoders and decoders, string and number conversion methods, and XML utilities.

android.os  Provides basic operating system services, message passing, and inter-process communication on the device.

android.graphics  Provides low level graphics tools such as canvases, color filters, points, and rectangles that let you handle drawing to the screen directly.

android.text    Provides classes used to render or track text and text spans on the screen.

android.database Contains classes to explore data returned through a content provider.

android.content Contains classes for accessing and publishing data on a device.

android.view  Provides classes that expose basic user interface classes that handle screen layout and interaction with the user.

android.widget  The widget package contains (mostly visual) UI elements to use on your Application screen.

android.app  Contains high-level classes encapsulating the overall Android application model.

android.provider Provides convenience classes to access the content providers supplied by Android.

android.telephony Provides APIs for monitoring the basic phone information, such as the network type and connection state, plus utilities for manipulating phone number strings.

android.webkit  Provides tools for browsing the web.

HelloActivity派生自android.app.Activity,这个类的派生关系如下

java.lang.Object
   ↳android.content.Context
    ↳android.content.ContextWrapper
     ↳android.view.ContextThemeWrapper
      ↳android.app.Activity
它有两个重要的成员函数。
onCreate(Bundle)
 是用来初始化activity的地方。

setContentView(int)
 把UI在activity上显示。view是可以在Activity上显示的,而view都已经资源化,所以只需要输入view的ID即可,这个ID在xml文件中维护。

Bundle类用于A mapping from String values to various Parcelable types. 具体作用目前还不明确。

setContentView(R.layout.main);这句话输入的是预置的一个view。也就是说每个android应用会有一个默认的view。具体见main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

这个view的文本就是输出结果,见string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, HelloActivity!</string>
    <string name="app_name">Hello</string>
</resources>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息