Increase/Decrease Seekbar progress with Button action?

Asked

Viewed 141 times

0

Someone can help: How to increase and decrease seekBarHomem progress through Button action?

seekBar

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    tv_QtdHomem = (TextView) findViewById(R.id.tv_QtdHomem);


    bt_MenosHomem = (Button) findViewById(R.id.bt_MenosHomem);
    bt_MaisHomem = (Button) findViewById(R.id.bt_MaisHomem);


    seekBarHomem = (SeekBar) findViewById(R.id.seekBarHomem);


    seekBarHomem.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public  void onProgressChanged(SeekBar seekBar, int i, boolean b) {

                 tv_QtdHomem.setText(""+i);

        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    bt_MaisHomem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {


        }
    });

   bt_MenosHomem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {


        }
    });
}

}

  • 2

    What methods of SeekBar? Can be the class documentation. Must have some method like seekBar.setProgress(int)

1 answer

3


Just use the methods setProgress and getProgress of SeekBar:

bt_MaisHomem.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        seekBarHomem.setProgress(seekBarHomem.getProgress() + 1)
    }
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.