1
Toast.makeText(this"사스가 토오스트"1).show();
cs

1
2
3
4
5
6
7
8
9
10
        toastBtn.setOnClickListener(new View.OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Toast.makeText(getApplicationContext(), "토오스트 떳다!"1).show();
                            //메인엑티비티가 멤버함수로(상속받아서) 가지고 있는 저 함수를 불러서
                            // 컨텍스트 객체를 받아오든가
            }
        });
cs

1
2
3
                Toast.makeText(MainActivity.this"토오스트 떳다!"1).show();
                              //이벤트 처리 객체를 가리키는 this가 아닌 
                              //엑티비티를 가리키는 this
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
        chk1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // TODO Auto-generated method stub
                Toast.makeText(MainActivity.this,
                        buttonView.getText()+"이"+(isChecked ? "선택":"해제")+"되었습니다."0).show();
                if(isChecked)
                    chk2.setChecked(false);
                
                
            }
        });
cs



ViewGroup은 자신 내부에 다른 위젯을 담을 수 있는 컨테이너

자바로 치면 프레임이나 패널 같은 녀석

ViewGrouo은 위젯들의 부모클래스인 View를 멤버로 유지할건데 ViewGroup자체도 View를 상속받음


ViewGroup : 뷰들을 담고있는 그룹, 뷰그룹은 뷰들을 배치하는 역할

다양한 뷰그룹(레이아웃)

- 리니어 레이아웃 : 박스모델, 사각형 영역들을 이용해 화면을 구성

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" 
    android:orientation="horizontal">
    
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="btn1"
        android:layout_weight="1"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="btn2"
        android:layout_weight="1"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="btn3"
        android:layout_weight="1"/>
 
</LinearLayout>
cs


- 상대 레이아웃  : 규칙기반 모델, 부모컨테이너나 다른 뷰와의 상대적 위치를 이용해 화면을 구성

- 프레임 레이아웃 : 기본단위 모델, 하나의 뷰만 보여줌, 가장 단순하지만 여러개의 뷰를 중첩한 후 각 뷰를 전환하여 보여주는 방식에 유리

- 테이블 레이아웃 : 격자 모델, 격자 모양의 배열을 이용하여 화면을 구성

- 스크롤 뷰 : 스크롤이 가능한 컨테이너, 뷰 또는 뷰그룹이 내부에 담아서 화면영역이 넘어갈때 스크롤 기능 제공


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:gravity="center">
        
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="btn1_1"
            android:layout_gravity="top"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="btn1_2"
            android:layout_gravity="center"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="btn1_3"
            android:layout_gravity="bottom"/>
    </LinearLayout>
    
    
    <Button
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:text="btn4"
        android:layout_weight="1"
        android:gravity="bottom|center"/>
cs




' IOT 기반 응용 SW과정 > Android, Arduino' 카테고리의 다른 글

Day89 안드로이드 엑티비티 전환  (0) 2016.07.25
Day88  (0) 2016.07.22
Day87  (0) 2016.07.21
Day85 안드로이드 액티비티  (0) 2016.07.19
Day84 안드로이드  (0) 2016.07.18

+ Recent posts