kotlin radiogroup,seekbar,edittext

Posted 霞腾龙升

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kotlin radiogroup,seekbar,edittext相关的知识,希望对你有一定的参考价值。

rg.setOnCheckedChangeListener{_,checkedId ->
when(checkedId){
R.id.radioButton ->{
Write[0]=1
Toast.makeText(this, radioButton.text.toString(),
Toast.LENGTH_SHORT).show()
}
R.id.radioButton2 ->{
Write[0]=2
Toast.makeText(this, radioButton2.text.toString(),
Toast.LENGTH_SHORT).show()
}
}
}
seekBar?.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
// Write code to perform some action when progress is changed.
editText.setText(seekBar.progress.toString())
}

override fun onStartTrackingTouch(seekBar: SeekBar) {
// Write code to perform some action when touch is started.
}

override fun onStopTrackingTouch(seekBar: SeekBar) {
// Write code to perform some action when touch is stopped.

Toast.makeText(this@MainActivity, seekBar.progress.toString() , Toast.LENGTH_SHORT).show()
}
})
editText.addTextChangedListener(object : TextWatcher{
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {

}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}

override fun afterTextChanged(s: Editable?) {
seekBar.setProgress(Integer.parseInt(editText.text.toString()))

}

})

以上是关于kotlin radiogroup,seekbar,edittext的主要内容,如果未能解决你的问题,请参考以下文章

listview 里有存在radiogroup,如何获得其选中的值?

android开发中 关于radiogroup

如何在选中复选框之前禁用 RadioGroup

android关于自定义seekbar控件的问题(将横向seekbar改成竖向seekbar)

一个 seekBar 的移动会影响另一个 seekBar

SeekBar