Search This Blog

Tuesday, July 18, 2017

Cach su dung SeekBar

this.seekBar = (SeekBar) findViewById(R.id.seekBar );
  
      this.seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          int progress = 0;
 
          // Khi giá trị progress thay đổi.
          @Override
          public void onProgressChanged(SeekBar seekBar, int progressValue, boolean fromUser) {
              progress = progressValue;
              textView.setText("Progress: " + progressValue + "/" + seekBar.getMax());
              Log.i(LOGTAG, "Changing seekbar's progress");
              Toast.makeText(getApplicationContext(), "Changing seekbar's progress", Toast.LENGTH_SHORT).show();
          }
 
          // Khi người dùng bắt đầu cử chỉ kéo thanh gạt.
          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
              Log.i(LOGTAG, "Started tracking seekbar");
              Toast.makeText(getApplicationContext(), "Started tracking seekbar", Toast.LENGTH_SHORT).show();
          }
 
          // Khi người dùng kết thúc cử chỉ kéo thanh gạt.
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
              textView.setText("Progress: " + progress + "/" + seekBar.getMax());
              Log.i(LOGTAG, "Stopped tracking seekbar");
              Toast.makeText(getApplicationContext(), "Stopped tracking seekbar", Toast.LENGTH_SHORT).show();
 
          }
      });
 

No comments:

Post a Comment