-1

I am working on an android app for a review app, I'm using seeker bars to get inputs from 1-7. I have copied code from the internet that seems to be the only solution but its throwing errors and I can't work out why.

'''

private var textview TextView;
private var seekBar SeekBar;
@Override
override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
textview = (TextView) findViewById(R.id.q1)

seekbar = (SeekBar) findViewById(R.id.q1a)
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
progressChangedValue = progress
}

'''

lewis
  • 19
  • 3

1 Answers1

0

Note: You have to add max value to SeekBar in xml or by adding seekbar.max = 7

private var textview TextView;
private var seekBar SeekBar;
@Override
override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
textview = (TextView) findViewById(R.id.q1)

seekbar = (SeekBar) findViewById(R.id.q1a)
seekbar.setOnSeekBarChangeListener(object : SimpleOnSeekBarChangeListener() {
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
      progressChangedValue = p1
   }
})
  • hey, that's all added and I appreciate the help, however its still throwing errors. Setting the variables have errors "property getter or setter expected" on both lines 1 and 2. The override fun onProgressChanged is throwing "override 'onProgressChanged' overrides nothing" error. If I remove the override, it said the function is never called. I creates a ProgressChangedValue variable – lewis Dec 10 '19 at 16:30