Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- IntelliJ
- Android
- tomcat
- 공정능력
- GIT
- 보조정렬
- Kotlin
- SQL
- R
- Java
- es6
- JavaScript
- xPlatform
- SPC
- SSL
- mapreduce
- hadoop
- plugin
- Sqoop
- table
- Eclipse
- Express
- MSSQL
- react
- NPM
- Spring
- vaadin
- Python
- mybatis
- window
Archives
- Today
- Total
DBILITY
안드로이드 spinner(combo) 사용법 본문
반응형
class MainActivity : AppCompatActivity() {
private val binding by lazy {
ActivityMainBinding.inflate(layoutInflater)
}
private var list = listOf("--선택하세요--","사과","바나나","귤")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//enableEdgeToEdge()
setContentView(binding.root)
/*ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}*/
var spinnerAdapter = ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,list)
with(binding) {
spinner.apply {
adapter = spinnerAdapter
onItemSelectedListener = object : OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>?,
view: View?,
position: Int,
id: Long
) {
var selectedItem = list[position]
tvSpinnerSelect.text = selectedItem
}
override fun onNothingSelected(parent: AdapterView<*>?) {
Log.d("onNothingSelected","이건 언제 동작하는겨?")
}
}
}
}
}
}
반응형
'android > kotlin' 카테고리의 다른 글
안드로이드 RecyclerView 기초 사용법 ( viewMoldel 적용 ) (0) | 2024.03.07 |
---|---|
안드로이드 RecyclerView 기초 사용법 (0) | 2024.03.05 |
안드로이드 RatingBar 사용법 (0) | 2024.02.28 |
안드로이드 seekbar 사용법 (0) | 2024.02.28 |
안드로이드 checkbox,toggle,switch 간단 사용법 (0) | 2024.02.28 |
Comments