본문 바로가기
비트 장기/안드로이드

9/13 안드로이드

by woohyun22 2018. 9. 13.

mainactivity.java

package com.example.admin.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//---------------------------------------------------
Log.d("t1", "호랑이 ");//logd 출력창 진행알림
//setContentView(R이 빨간색일때 1. 안드로이드 로딩이 다 안되있을때 기다리면됨. 2. xml파일에 문법이 잘못입력되었을때)
//이게 안되면 지워버려라!
}
void func01(View v){//함수안에 함수넣을수있다. onCreate안에는 못들어간다.
Log.d("t2", "코끼리");
}

public void func02(View v) {

}
}


activity_main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<Button
android:id="@+id/btn01"
android:onClick = "func01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />

<Button
android:id="@+id/btn02"
android:onClick = "func02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />

</LinearLayout>



728x90

'비트 장기 > 안드로이드' 카테고리의 다른 글

9/14 안드로이드  (0) 2018.09.14

댓글