Hello Android

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

直接贴图,懒得打字。反正Hello World程序到处都是。。。。

[img]http://dl.iteye.com/upload/attachment/240430/eca8d8f9-9e40-3eb5-a995-159ac9f02f3d.png[/img]

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

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

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

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

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

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

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

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画上去。。

看一下运行结果吧。

[img]http://dl.iteye.com/upload/attachment/240455/036c1e0a-a882-3ef4-b0d3-df0bfcb4623b.png[/img]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值