这一篇我就从API Demos/Activity/Hello World开始吧。学习任何一个语言,我相信大家都是从hello world开始。
首先,我们用Eclipse打开API Demos工程,这里我只介绍android 2.2的sample code。选择File--->New--->Project...,在弹出的对话框种选择Android Sample Project,
然后,选择android 2.2,最后选择ApiDemos,点finish,就打开了。
![](http://hi.csdn.net/attachment/201110/31/0_13200841292yG9.gif)
![](http://hi.csdn.net/attachment/201110/31/0_1320084159Wvur.gif)
我们来看看代码吧。哇!这么多,从哪看啊!不急,每个android工程都有个AndroidManiFest.xml, 我不会一句一句介绍它,我会在后面一点一点的讲解,最后等我们看完了整个Activity demo。
直接上代码了HelloWorld.java:
public class HelloWorld extends Activity
{
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState)
{
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// See assets/res/any/layout/hello_world.xml for this
// view layout definit