Ivan_Pig 发表于 2013-1-28 18:56:56

Hello Android

Intellij IDEA是我最喜欢的IDE,所以使用Intellij IDEA开发Android。安装Android插件,配置好Android的JDK就可以开发了。

      直接贴图,懒得打字。反正Hello World程序到处都是。。。。
      
http://dl.iteye.com/upload/attachment/240430/eca8d8f9-9e40-3eb5-a995-159ac9f02f3d.png

http://dl.iteye.com/upload/attachment/240432/37b0603e-170d-314b-8c6a-a2a268a26764.png

http://dl.iteye.com/upload/attachment/240434/ebb1a915-21d0-34a0-96b5-3b58792e64e6.png

http://dl.iteye.com/upload/attachment/240436/978ef328-14d0-3f92-a96e-4bc29c06be16.png

http://dl.iteye.com/upload/attachment/240438/e5afb54e-a220-33f7-8f2b-1ba07f11ad02.png

http://dl.iteye.com/upload/attachment/240440/65396d15-2d57-3d05-a82d-75ed7c5cfa3c.png
      HelloWorld就搞定了。。。。

       Android项目结构如下。乍看之下目录挺多的,其实各司其守,不过做惯了j2ee的人,刚开始还是有些不习惯。

http://dl.iteye.com/upload/attachment/240448/006fc211-fa82-3ca9-90bc-ba35d9727374.png

       R.java是Android用的。
       libs下面肯定是需要的lib啦。
       drawable下面是图片。
       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>
   其中LinearLayout是布局,TextView是个显示组件,显示android:text="@string/hello"所表示的字符串,@string/hello指向strings.xml里面的hello标签所对应的值。这里就是Hello World, Lop!

       strings.xml是字符串,可国际化使用。

<?xml version="1.0" encoding="utf-8"?><resources>    <string name="hello">Hello World, Lop!</string>    <string name="app_name"></string></resources>

       HelloAndroid.java就是代码了。
      package org.ivan;import android.app.Activity;import android.os.Bundle;/** * Created by IntelliJ IDEA. * User: Ivan * Date: 2010-4-26 * Time: 22:18:30 */public class HelloAndroid extends Activity {    /**   * Called when the activity is first created.   */    @Override    public void onCreate(Bundle savedInstanceState) {      super.onCreate(savedInstanceState);      setContentView(R.layout.main);    }}
实际就一句代码,setContentView(R.layout.main);,将main画上去。。

    看一下运行结果吧。
   
http://dl.iteye.com/upload/attachment/240455/036c1e0a-a882-3ef4-b0d3-df0bfcb4623b.png
页: [1]
查看完整版本: Hello Android