Android Studio/과제들

HelloWorld (어플 기본과제)

ElectricShock 2017. 7. 13. 01:44

Android Studio 켜고

File >> New >> New Project



http://instructables.tistory.com/282

OS확인 방법을 통해서 API를 맞춰준다.







New Class 생성하는법

Package상에 우클릭 >> New >> Java Class



코드 자동완성기능 (=Code Completion)은 Ctrl+Space 이다.


▼List <E> 를 선택한다.



51쪽 (PDF기준)

let’s verify that Android Studio is configured properly 

to ignore the member name prefixes m and s.

Click File ▶ Settings ▶ Code Style ▶ Java ▶ Code

Apply >> OK



SandBox Class안에서 오른편 코딩공간에 Cursor를 위치시키고,

Alt + Insert를 누른후, Constructor를 select한다.





뭔가 생성이 되긴했다.


▼아래 그림처럼 Cursor를 위치시키고, Alt+Insert를 누르고 Getters&Setters 선택




▼이제 Extends(=상속)를 실험해보자.

타이핑하고 Alt+Enter 를 눌러서 Import시킨다. (=클레스로 등록)


Hierarchy View (Ctrl+H) ---- 오른편에 뜬다.


▼다시 SandBox Class로 돌아와서 RectShape다음에 Cursor를 두고

Alt+Insert를 눌러서 Override Methods를 선택



Let’s override the hasAlpha() method from Shape


▼Overridden 된 상태


Modify the return statement of hasAlpha() to always return true.


이제 toString을 생성시켜보자.

아래그림처럼 Cursor를 위치시키고 Alt+Insert



▼이제 Delegate Method를 생성시키자


▼add(object : E) : boolean 과 유사한 걸 선택한다.


Delegated Methods are not overridden methods,

so you can rename your proxy method to whatever you want.

s를 object 등등 아무이름으로나 바꿀수 있다. (PDF에는 object로 바뀌어있다.)

▼Rename the Delegated Method


▶File▶Settings▶Live Templates

아래 그림처럼 plain이 선택된 채로 오른쪽 끝의 초록색 +버튼을 누른다.

그리고 Live Template를 택한다.


▼Abbreviation, Description, Template Text를 채워넣자.



You just created a custom live template called cb

Purple word $SELECTION$ below is a variable.



Ctrl+J : Invoke한다. a scope-sensitive한 Live Template List를 (아래사진)

Ctrl+Alt+J : Invoke한다. a scope-sensitive한 Surround with Live Template List를



psfs를 Invoke하는법

sandbox.java 선언부(=declarations) dptj

mGreetings의 definition에서

psfs를 typing하고 Ctrl+J를 누르면 된다.

아래그림 참고.