Unknown On 2014년 6월 30일 월요일

xml 코드 부분 
<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="mOnButton"
    android:text="DOWN" />


빨간 부분, 즉 mOnButton 이라는 이벤트를 등록하고
파란부분, 즉 button1 이라는 ID로 사용하면 된다.


메인 엑티비티 부분 

public void mOnButton(View v) {
    switch (v.getId()) {
    case R.id.button1 :
        //이벤트 내용
        break;
    }
}


같은 이름의 함수를 만들고, 버튼 아이디에 따른 처리를 해주면 끝.



Leave a Reply

Subscribe to Posts | Subscribe to Comments

Powered by Blogger.