🀷🏼‍♀️ Etc.../- C, C++, Python, Android

[μ•ˆλ“œλ‘œμ΄λ“œ μŠ€νŠœλ””μ˜€] μ•ˆλ“œλ‘œμ΄λ“œ μœ„μ ― 닀루기2 (μ»΄νŒŒμš΄λ“œ λ²„νŠΌ: μ²΄ν¬λ°•μŠ€, λΌλ””μ˜€ λ²„νŠΌ, μŠ€μœ„μΉ˜/ν† κΈ€ λ²„νŠΌ)

Wonit 2020. 4. 30. 20:46

μ»΄νŒŒμš΄λ“œ λ²„νŠΌ

compoundButton ν΄λž˜μŠ€λŠ” Button 클래슀의 ν•˜μœ„ ν΄λž˜μŠ€μ΄λ‹€. κ·Έ ν•˜μœ„ λͺ©λ‘μ—λŠ”

  • CheckBox
  • ToggleButton
  • RadioButton

이 μžˆλ‹€. 이제 이 ν•˜μœ„ ν΄λž˜μŠ€μ— λŒ€ν•΄ μ•Œμ•„λ³΄μž.

CheckBox

μ²΄ν¬λ°•μŠ€λŠ” 클릭될 λ•Œ λ§ˆλ‹€ μƒνƒœκ°€ 체크 λ˜λŠ” μ–Έμ²΄ν¬λ‘œ 바뀐닀.

 

μ—¬λŸ¬ 개의 μ²΄ν¬λ°•μŠ€κ°€ μžˆμ–΄λ„ μ„œλ‘œ λ…λ¦½μ μœΌλ‘œ λ™μž‘ ν•œλ‹€λŠ” νŠΉμ§•μ΄ μžˆμ–΄μ„œ μ—¬λŸ¬ 개λ₯Ό λ™μ‹œμ— 체크할 λ•Œ μ‚¬μš©λœλ‹€.

 

좜처 : http://klutzy.github.io/

 

<CheckBox
          android:id="@+id/androidBox"
          android:text="μ•ˆλ“œλ‘œμ΄λ“œ νœ΄λŒ€ν°"
          android:checked="true" />
<CheckBox
          android:id="@+id/iphoneBox"
          android:text="아이폰 νœ΄λŒ€ν°" />

 

μœ„μ™€ 같이 μ½”λ“œλ₯Ό μˆ˜ν–‰ν•œλ‹€λ©΄ μ•„λž˜μ™€ 같은 κ²°κ³Όκ°€ λ‚˜μ˜¨λ‹€.

 

μ²΄ν¬λ°•μŠ€

 

이λ₯Ό 톡해 μ•Œ 수 μžˆλŠ” 것은 checked의 κΈ°λ³Έ default 값은 falseλΌλŠ” 점...

 

Switch와 ToggleButton

 

μŠ€μœ„μΉ˜μ™€ ν† κΈ€ λ²„νŠΌμ€ μƒκΉ€μƒˆλ§Œ λ‹€λ₯΄κ³  온/μ˜€ν”„λ₯Ό ν‘œν˜„ν•˜λŠ” μš©λ„λŠ” λ™μΌν•˜λ‹€.

 

좜처 : http://klutzy.github.io/

 

<ToggleButton
              android:id="@+id/tgBtn1"
              android:checked="true"/>
<ToggleBUtton
              android:id="@+id/tgBtn2"/>

 

 

 

 

RadioButtonκ³Ό RadioGroup

 

λΌλ””μ˜€λ²„νŠΌμ€ μ²΄ν¬λ°•μŠ€μ™€ xml / java λ©”μ„œλ“œκ°€ λΉ„μŠ·ν•˜μ§€λ§Œ μš©λ„λŠ” λ‹€λ₯΄λ‹€.


RadioButton을 μ‚¬μš©ν•  λ•ŒλŠ” ν•œ κ°€μ§€λ§Œ κΈ°μ–΅ν•˜μž. 체크해야할 것이 μ—¬λŸ¬κ°œ 쀑 ν•˜λ‚˜μΌ 경우

 

RadioGroup은 λΌλ””μ˜€ λ²„νŠΌμ„ λ‹΄μ•„μ£ΌλŠ” μΌμ’…μ˜ μ»¨ν…Œμ΄λ„ˆ 역할을 ν•˜λŠ”λ° λΌλ””μ˜€ λ²„νŠΌμ˜ λ²”μœ„λ₯Ό μ œν•œν•˜λŠ”λ° μ‚¬μš©λ˜κ³€ ν•œλ‹€.

 

 

<RadioGroup
            android:id="@+id/radioGroup">
              <RadioButton
                         android:id="@+id/btn"/>
              <RadioButton
                         android:id="@+id/btn2"/>
</RadioGroup>