[Android/예제] Hello World
android/구글관련/예제 2009. 1. 7. 21:01간단한 설명
어디서나 볼 수 있는 Hello World.
안드로이드 어플리케이션은 다음과 같은 덩어리로 이루어진다.
자세한것들은 다음에 다루도록 하자.
소스코드
src/com.ggaman.android.sample.Test.java
src/com.ggaman.andorid.sample.R.java
res/layout/main.xml
res/values/strings.xml
res/drawable/icon.png
AndroidManifest.xml
어디서나 볼 수 있는 Hello World.
안드로이드 어플리케이션은 다음과 같은 덩어리로 이루어진다.
1. 진짜 소스 ( 개발자가 직접 작성해야 하는것 )
2. 레이아웃 관련 XML
3. 각종 리소스 ( 이미지, 각종 단어들... )
4. 어플리케이션 관련 설정
이중에서 2,3,4는 이클립스 플러그인에서 쉽게 작성할 수 있도록 도와 준다.
2. 레이아웃 관련 XML
3. 각종 리소스 ( 이미지, 각종 단어들... )
4. 어플리케이션 관련 설정
이중에서 2,3,4는 이클립스 플러그인에서 쉽게 작성할 수 있도록 도와 준다.
자세한것들은 다음에 다루도록 하자.
소스코드
src/com.ggaman.android.sample.Test.java
- package com.ggaman.android.sample;
- import android.app.Activity;
- import android.os.Bundle;
- public class Test extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
- }
src/com.ggaman.andorid.sample.R.java
- /* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
- package com.ggaman.android.sample;
- public final class R {
- public static final class attr {
- }
- public static final class drawable {
- public static final int icon=0x7f020000;
- }
- public static final class layout {
- public static final int main=0x7f030000;
- }
- public static final class string {
- public static final int app_name=0x7f040001;
- public static final int hello=0x7f040000;
- }
- }
res/layout/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>
res/values/strings.xml
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <string name="hello">Hello World, Test</string>
- <string name="app_name">AppName</string>
- </resources>
res/drawable/icon.png
AndroidManifest.xml
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.ggaman.android.sample"
- android:versionCode="1"
- android:versionName="1.0.0">
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:name=".Test"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
- </manifest>