new로 생성
start를 누르고 launch를 누르면 부팅이된다.
프로젝트를 만들고
android2.2버전->
xml로 생성
java언어로 생성
HelloWorld.java
package com.example.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//TextView textView = new TextView(this);
//textView.setText("안녕하세요^^ 안드로이드!");
HelloView myView=new HelloView(this);
setContentView(myView);
}
}
HelloView.java
source -> override에서 onDraw를 추가해서 사용
ctrl shift o 키를 누르면 Paint() 임포트를 전체적으로 해준다.
helloView.java
package com.example.helloworld;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
public class HelloView extends View {
public HelloView(Context context) {
super(context);
setBackgroundColor(Color.WHITE);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawText("Hello World!", 0, 20, new Paint());
super.onDraw(canvas);
}
}
'개인 공부방 > Android' 카테고리의 다른 글
4강 안드로이드 지도 API (0) | 2012.01.08 |
---|---|
apk파일 가상머신에 설치하기 (0) | 2012.01.08 |
apk 파일 만들기 (0) | 2012.01.08 |
안드로이드 설치 (0) | 2012.01.07 |