Skip to content

Instantly share code, notes, and snippets.

Created July 12, 2022 06:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
【Java】How to Use SeekBar 5
package com.example.seekbarsample;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
TextView textView = findViewById(;
SeekBar seekbar = findViewById(;
Button button = findViewById(;
// 初期値を表示
textView.setText(seekbar.getProgress() + "");
// 「リセット」を押したら50にする
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// SeekBarイベント
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
textView.setText(i + "");
public void onStartTrackingTouch(SeekBar seekBar) {
public void onStopTrackingTouch(SeekBar seekBar) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment