小编以为无论学习什么编程的时候,第一个程序都是要求打印输出一个"HelloWorld!",那就从最简单的HelloWorld开始吧!哈哈~~~~android
以下图:编程
可是值得注意的是:在选择下面API版本的时候必定要想到版本问题,否则就会报错哈,小编深有体会~~~~app
而后next便可eclipse
next以后会来到这样一个页面,注意必定要指定好工做空间ide
继续next,后面的这几步就直接所有next、next、next就好啦学习
点击finish完成工程的建立,这时候就能够看到以下的一个界面this
可是小编想讲的并非这个~~而是本身写的,不是默认的!spa
这里是自动生成这个按钮代码的,不须要咱们本身去写,是否是很方便呢?3d
选中textView1(这里是为了下一步的方便)code
注意:下面的代码除了有注释解释的那两行都是自动生成的,不须要咱们敲,因此是否是很方便呢?
package com.example.helloworld; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.TextView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //定位textView1控件 TextView tv1=(TextView)this.findViewById(R.id.textView1); //给控件赋值 tv1.setText("这是个人第一个Android程序:HelloWorld!"); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }
到这里呢咱们就拥有了属于本身的第一个HelloWorld程序了。
一、建立Android工程
二、直接运行,默认的就是打印输出HelloWorld
三、本身动手编写,在这里你们是否是发现很是的方便呢?这就是使用eclipse ADT的好处之一。