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

ITGenerations

라디오 버튼 만들기 안드로이드 본문

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

라디오 버튼 만들기 안드로이드

ITGenerations 2018. 1. 19. 14:09
package com.example.ryan.myapplication;

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

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onRadioButtonClicked(View view){
boolean checked = ((RadioButton)view).isChecked();
switch (view.getId()){
case R.id.radio_red:
if(checked)
Toast.makeText(getApplicationContext(),((RadioButton)view).getText(),Toast.LENGTH_SHORT).show();
break;

case R.id.radio_blue:
if(checked)
Toast.makeText(getApplicationContext(),((RadioButton)view).getText(),Toast.LENGTH_SHORT).show();
break;
}
}


}

다중 체크 불가능