«   2024/12   »
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
Tags
more
Archives
Today
Total
관리 메뉴

ITGenerations

안드로이드 - 토글 버튼 on, off 본문

프로그래밍/안드로이드특강

안드로이드 - 토글 버튼 on, off

ITGenerations 2018. 1. 19. 16:01
package com.example.ryan.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import android.widget.ToggleButton;

public class MainActivity extends AppCompatActivity {

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


public void onToggleClicked(View view){
//Is the toggle on?
boolean on=((ToggleButton)view).isChecked();
if(on)
Toast.makeText(getApplicationContext(),"Checked",Toast.LENGTH_SHORT).show();
else
Toast.makeText(getApplicationContext(),"Not Checked",Toast.LENGTH_SHORT).show();

}


}