This is a strange one. I have 2 seek bars and I have established a listener for both. However when I slide the thumbbar for one seekbar - it updates that seekbar AND it also moves the thumb of the second seekbar.
If I move the thumb on the second seekbar - it only changes the second sekbar NOT the first.
If I remove the listener for the first seekbar - I get the same problem.
I have attached code pertiaing to the seekbar listeners. mSeekBarA is the first one. mSeekBarB is the second.
mSeekBarA.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
{
#Override
public void onStopTrackingTouch(SeekBar seekBar)
{
}
#Override
public void onStartTrackingTouch(SeekBar seekBar)
{
// TODO Auto-generated method stub
}
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
On_SFX_Volume_Change(progress);
}
});
mSeekBarB.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
{
#Override
public void onStopTrackingTouch(SeekBar seekBar)
{
}
#Override
public void onStartTrackingTouch(SeekBar seekBar)
{
// TODO Auto-generated method stub
}
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
On_MUS_Volume_Change(progress);
}
});
Thank you !
How did you instantiate these sliders? I bet that they are actually referring to the same instance. Possibly you added the same slider to the layout instead of adding the each one individually.
Related
I need to run a method every time the position of my seekbar is changed.
It does not matter:
how far it has moved
the direction
if its at the end or the start.
just that it has changed
is there a equivalent to onclickListener() for a seekbar.
Use this method provided by SeekBar class:
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//progress changed
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
The seekbar has a setOnSeekBarChangeListener. Check this for more details https://developer.android.com/reference/android/widget/SeekBar.OnSeekBarChangeListener.html
seekBar.setOnSeekBarChangeListener(
new OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar,
int progresValue, boolean fromUser) {
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
I want to implement 3 vertical SeekBar in a page so that it looks like a bar chart. When user drags any one of the SeekBar the value corresponding to the y axis should be retrieved for that. Other SeekBar should remain in their original state.
Our idea is to implement interactive bar chart with dragging feature. Since that is not possible in open library, we decided to use seek bar instead by increasing the width.
Any sample app with this will be helpful.
public class multiverticleseek extends Activity {
/** Called when the activity is first created. */
TextView textView3,textView2,textView1;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.multiseek);
textView1 = (TextView)findViewById(R.id.textView1);
textView2 = (TextView)findViewById(R.id.textView2);
textView3 = (TextView)findViewById(R.id.textView3);
bar1=(VerticalSeekBar)findViewById(R.id.seekBar1);
bar2=(VerticalSeekBar)findViewById(R.id.seekBar2);
bar3=(VerticalSeekBar)findViewById(R.id.seekBar3);
bar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
textView1.setText(Integer.toString(progress)+"%");
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
bar2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
textView2.setText(Integer.toString(progress)+"%");
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
bar3.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
textView3.setText(Integer.toString(progress)+"%");
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
i m using seekbar in a game in which i want it to set to zero location by default when user leave it
verticalSeekBar=(VerticalSeekBar)findViewById(R.id.vertical_Seekbar);
vsProgress=(TextView)findViewById(R.id.vertical_sb_progresstext);
tv1=(TextView)findViewById(R.id.text1);
verticalSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
setProgress(0);
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
#Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
vsProgress.setText(progress+"");
if(progress==10)
{
check();
}
}
Use
VerticalSeekBar.setProgress(0);
instead of
seekBar.setProgress(0);
How to call from code onProgressChanged for SeekBar ? Is there similiar stuff like perform click for button ?
Use this listener on seek bar object
SeekBar seek=new SeekBar(this);
seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
#Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// Here call your code when progress will changes
}
});
I need to dynamically move 2 seekbars. While the user moves one, the other will have to move also accordingly to the values of the first.
I've created 2 seekbars but they move independent from each other, how can i "link" them so, for ex. the second seekbar moves 1/10th of the first?
Thanks
seekBarSM.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
#Override
public void onProgressChanged(SeekBar seekBarSM, int progress,
boolean fromUser) {
seekBarSMValue.setText(String.valueOf(progress));
}
#Override
public void onStartTrackingTouch(SeekBar seekBarSM) {
}
#Override
public void onStopTrackingTouch(SeekBar seekBarSM) {
}
});
seekBarSF.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
#Override
public void onProgressChanged(SeekBar seekBarSF, int progress,
boolean fromUser) {
seekBarSFValue.setText(String.valueOf(progress));
}
#Override
public void onStartTrackingTouch(SeekBar seekBarSF) {
}
#Override
public void onStopTrackingTouch(SeekBar seekBarSF) {
}
});
In the onProgressChanged() of one, just call setProgres() on the other with the value it should change to.