Adagio non molto
[Android] Hello World 이해하기 기초 본문
자바를 얼추 공부하고 안드로이드를 들어가자마자 위협하는 XML !! ㅡㅜ
XML은 따로 공부하지 않고 그저 이해하기로 결정...
일단 기본적으로 Hello World 소스(?)는
중요한건 setContentView !
이 메소드의 기능은 리소스를 읽고 레이아웃에 포함된 뷰를 생성하여 액티비티에 채우는 것 !
즉, 위에서는 R.layout.main이 리소스역할을 하는 것.
그래서 main.xml 파일을 들어가면 레이아웃 구조를 볼 수 있다.
XML은 따로 공부하지 않고 그저 이해하기로 결정...
일단 기본적으로 Hello World 소스(?)는
package exam.adroidfirst;
import android.app.Activity;
import android.os.Bundle;
public class AndroidFirstActivity 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.xml 파일을 들어가면 레이아웃 구조를 볼 수 있다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
xml 버전과 인코딩 방식이 맨 윗줄에 있고...
LinearLayout을 설정하고, 글을 출력하는 TextView가 있다.
그 중 굵은 문장 즉, 네임스페이스 android를 달고 있는 text속성이 있다.
굵은 문장은 "@string/hello"를 출력하라 !
hello가 무엇인지 보기 위해 string.xml로 넘어가면.
xml 버전과 인코딩 방식이 맨 윗줄에 있고...
LinearLayout을 설정하고, 글을 출력하는 TextView가 있다.
그 중 굵은 문장 즉, 네임스페이스 android를 달고 있는 text속성이 있다.
굵은 문장은 "@string/hello"를 출력하라 !
hello가 무엇인지 보기 위해 string.xml로 넘어가면.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, AndroidFirstActivity!</string>
<string name="app_name">AndroidFirst</string>
</resources>
hello는 Hello World, AndroidFirstActivity! 라고 되어있다.
결국 프로그램을 실행하면 저 문장이 출력되는 것이다 !!
에휴 ㅜ 겨우 이해한 느낌... ㄷ
hello는 Hello World, AndroidFirstActivity! 라고 되어있다.
결국 프로그램을 실행하면 저 문장이 출력되는 것이다 !!
에휴 ㅜ 겨우 이해한 느낌... ㄷ
'Study > JAVA' 카테고리의 다른 글
[Android] AudioRecord vs MedioRecorder (1) | 2015.09.19 |
---|---|
[Android] 스택베이스 공학용계산기 잠정 중단... (0) | 2012.04.07 |
[Android] Button 만들기 - 코드 분석 (0) | 2011.12.21 |
Comments