Hello Android
16lz
2021-12-04
Intellij IDEA是我最喜欢的IDE,所以使用Intellij IDEA开发Android。安装Android插件,配置好Android的JDK就可以开发了。
直接贴图,懒得打字。反正Hello World程序到处都是。。。。
HelloWorld就搞定了。。。。
Android项目结构如下。乍看之下目录挺多的,其实各司其守,不过做惯了j2ee的人,刚开始还是有些不习惯。
R.java是Android用的。
libs下面肯定是需要的lib啦。
drawable下面是图片。
main.xml是布局。
其中LinearLayout是布局,TextView是个显示组件,显示android:text="@string/hello"所表示的字符串,@string/hello指向strings.xml里面的hello标签所对应的值。这里就是Hello World, Lop!
strings.xml是字符串,可国际化使用。
HelloAndroid.java就是代码了。
实际就一句代码,setContentView(R.layout.main);,将main画上去。。
看一下运行结果吧。
直接贴图,懒得打字。反正Hello World程序到处都是。。。。
HelloWorld就搞定了。。。。
Android项目结构如下。乍看之下目录挺多的,其实各司其守,不过做惯了j2ee的人,刚开始还是有些不习惯。
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画上去。。
看一下运行结果吧。
更多相关文章
- Android(安卓)内核开发初步
- Android(安卓)Studio单元测试
- android JNI (二) 第一个 android工程
- Android(安卓)增加对鼠标的支持
- 基于蓝牙socket开发Android蓝牙通信
- Binder驱动的实现
- Android/java 多线程(五)-ThreadPoolExecutor线程池的使用
- Android实例收藏
- zz浅谈android的selector,背景选择器