안드로이드

[안드로이드 강좌 예제 따라하기 1] 기본틀 클릭 가능한 만들어 메뉴만들기

App.SHIN 2014. 11. 2. 02:18

안녕하세요 안드로이드 강좌를 시작하게된 Shin 입니다.


res/layout/activity_main.xml

<linearlayout 
	xmlns:android="http://schemas.android.com/apk/res/android" 
	android:layout_width="match_parent" 
	android:layout_height="match_parent">
<textview 
	android:id="@+id/calculator" 
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content" 
	android:text="@string/hello_world" 
	android:textappearance="?android:attr/textAppearanceLarge">
</textview>
</linearlayout>


자바파일 내용은~

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}
}


이렇게만 수정해도 hello world 가 찍히네요

LinearLayout 은  좌에서 우 , 위에서 아래로 추가되는 틀이 만들어집니다.

기본으로 위에서 아래로 됩니다.

만약 명시적으로 지정하시고 싶으시면   android:orientation 속성으로 지정하시면 됩니다.  값은 vertical , horizontal 이 있습니다.

horizontal 은 좌에서 우로 vertical 은 위에서 아래로입니다.


그럼 실행해볼까요?

우선 휴대폰을 셋팅합니다~

설정 > 개발자옵션 > 개발자옵션 ON > USB디버깅 켜기 > USB디버깅 허용 확인




설정이 끝났다면 실행을 합니다. 

프로젝트를 선택하고 Run As > Android Application 을 선택합니다.

위에설정을 하고  usb연결을 해두었다면 아래와 같이 단말이 보입니다.



실행결과 화면 ~


예제 프로젝트입니다. 

ShinExample.zip