SoFunction
Updated on 2025-04-07

Detailed explanation of the usage of the SeekBar control in Android

package .mars_2400_seekbar;

import .;
import .;
import .;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;

public class MainActivity extends Activity implements OnSeekBarChangeListener {
  private TextView tv;
  private SeekBar sb;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    (savedInstanceState);
    setContentView(.activity_main);
    tv = (TextView) findViewById(.textView1);
    sb = (SeekBar) findViewById();
    (this);
  }

  @Override
  public void onProgressChanged(SeekBar seekBar, int progress,
      boolean fromUser) {
    // TODO Auto-generated method stub
    ("Progress is " + progress
        + (fromUser ? " Trigger" : " Nontrigger") + " by user.");
  }


 @Override
  public void onStartTrackingTouch(SeekBar seekBar) {
    // TODO Auto-generated method stub
  	("onStart-->"+());
  }

 @Override
  public void onStopTrackingTouch(SeekBar seekBar) {
    // TODO Auto-generated method stub
  	("onStop-->"+());
  }


  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu);
    return true;
  }

}

 activity_main.xml

 

<?xml version="1.0" encoding="UTF-8"?>
 <LinearLayout xmlns:andro
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     >
 
<TextView android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:/>

<SeekBar android:
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"/>
 </LinearLayout>

The above is the detailed explanation of the usage of the SeekBar control brought to you by the editor. I hope it will be helpful to everyone and support me more~