Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Instead of inline creating the SeekBar.OnSeekBarChangeListener, create a member variable of type SeekBar.OnSeekBarChangeListener. When you want it to turn it on, you can pass the variable to it. When you want to turn it off, you can pass it the null. </p> <pre><code>private SeekBar sbt; //Not sure where this gets initialized in your code. private SeekBar.OnSeekBarChangeListener mListener = new SeekBar.OnSeekBarChangeListener() { int progressChanged = 0; @Override public void onStopTrackingTouch(SeekBar seekBar) { // Toast.makeText(ProductDetailsInfoActivity.this,"seek bar progress:"+progressChanged, // Toast.LENGTH_SHORT).show(); // TODO Auto-generated method stub } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromuser) { //recalcpriceornot=false; // TODO Auto-generated method stub //Toast.makeText(ProductDetailsInfoActivity.this, String.valueOf(progress), Toast.LENGTH_SHORT).show(); try { //if (recalcpriceornot) { GetItemPriceCalculation(progress); recalctotalprice();} } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } progressChanged = progress; if(progress &lt;= 100){ setProgressBarColor(sbt,Color.GREEN); }else{ setProgressBarColor(sbt,Color.RED); } } }); void enableListener() { sbt.setOnSeekBarChangeListener(mListener); } void disableListener() { sbt.setOnSeekBarChangeListener(null); } </code></pre> <p>You can also let this object implement/extends the OnSeekBarChangeListener and not keep a variable to the listener. In which case the enable will pass in "this". </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload