๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ์žฅ์›์ต ๊ธฐ์ˆ ๋ธ”๋กœ๊ทธ
๐Ÿคท๐Ÿผ‍โ™€๏ธ Etc.../- C, C++, Python, Android

[์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค] ์•ˆ๋“œ๋กœ์ด๋“œ ์œ„์ ฏ ๋‹ค๋ฃจ๊ธฐ2 (์ปดํŒŒ์šด๋“œ ๋ฒ„ํŠผ: ์ฒดํฌ๋ฐ•์Šค, ๋ผ๋””์˜ค ๋ฒ„ํŠผ, ์Šค์œ„์น˜/ํ† ๊ธ€ ๋ฒ„ํŠผ)

by Wonit 2020. 4. 30.

์ปดํŒŒ์šด๋“œ ๋ฒ„ํŠผ

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>

 

 

๋Œ“๊ธ€