iOS를 사랑하는 AOS 개발자
[Android/Kotlin] RadioButton 간단 사용법(feat. strings.xml) 본문
Android ( Kotlin )/개발
[Android/Kotlin] RadioButton 간단 사용법(feat. strings.xml)
아사안개 2022. 11. 26. 17:00반응형
SMALL
👼🏻 초보 안드로이드 개발자가 매번 구글링하기 싫어서 정리하는 블로그 👼🏻
안녕하세요! 🙋🏻♀️
RadioButton Kotlin Version 으로 작성해볼거에요!!!
Java 랑 다른점이 거의 없지만, Java버전에서 string.xml 간단 사용법 및 작성법을 작성했으니 참고해주세용!
2021.12.21 - [Android ( JAVA )/개발] - [Android] RadioButton 간단 사용법(feat. strings.xml)
[Android] RadioButton 간단 사용법(feat. strings.xml)
👼🏻 초보 안드로이드 개발자가 매번 구글링하기 싫어서 정리하는 블로그 👼🏻 [Android] CheckBox 간단 사용법 👼🏻 초보 안드로이드 개발자가 매번 구글링하기 싫어서 정리하는 블로그 👼🏻
devziner.tistory.com
View 는 똑같으니 넘어갈게요 😸
class MainActivity : AppCompatActivity() {
lateinit var radioGroup:RadioGroup
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
radioGroup = findViewById(R.id.rg_01)
radioGroup.setOnCheckedChangeListener { group, checkedId ->
var str = ""
val radioButton = findViewById<RadioButton>(checkedId)
str = radioButton.text.toString()
Toast.makeText(this@MainActivity, "$str 주세요!!", Toast.LENGTH_SHORT).show()
}
}
}
Java랑 거의 똑같아요!!!
RadioButton 은 사용성에 있어 중복체크가 있으면 안되니 꼭 그룹으로 묶어서 사용하셔야 좋아요!
틀린부분이 있거나, 궁금하신게 있거나, 그냥 아무말이나 하고싶으면 댓글 남겨주세요 🥴
봐주셔서 감사합니다 🥰
반응형
LIST
'Android ( Kotlin ) > 개발' 카테고리의 다른 글
[Android/Kotlin] View.getVisibility 값 확인 (0) | 2023.05.07 |
---|---|
[Android/Kotlin] CheckBox 간단 사용법 (0) | 2022.11.26 |
[Android/Kotlin] 안드로이드 앱 내에서 문자보내기 (0) | 2022.11.20 |
[Android/Kotlin] 안드로이드 앱 내에서 전화걸기 (0) | 2022.11.20 |
Comments