The automatically generated code is onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean), instead of onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) as in other websites and Youtube tutorials, after clicking "implement members" in Kotlin (Kotlin plugin version: 1.4.32-release-Studio4.1-1, the latest version shown in Android Studio Settings after check update). The function works well, but it would be better if it has descriptive parameters. How to set the system to let it show the descriptive parameters? Thank you in advance!
The code:
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.SeekBar
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
idSeekBar.setOnSeekBarChangeListener(object:SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
tvShowData.text = p1.toString() }
override fun onStartTrackingTouch(p0: SeekBar?) { }
override fun onStopTrackingTouch(p0: SeekBar?) { }
})
}
}
The reason is you don't have downloaded current api sdk for android. In android studio, for example, you can see the defination of setOnSeekBarChangeListener
by ctrl + space
, and android studio will tell you that you can download api sdk. After downloading, you can try it again. Hopes useful.