packagecom.example.yu_k.seekbartest;
importandroid.support.v7.app.AppCompatActivity;
importandroid.os.Bundle;
importandroid.widget.SeekBar;
importandroid.widget.TextView;
importjava.util.ArrayList;
public classMainActivityextendsAppCompatActivity {
privateSeekBarmSeekBar;
privateTextViewmTextView;
privateTextViewmTextView2;
@Override
protected voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSeekBar= (SeekBar) findViewById(R.id.seekBar);
mTextView= (TextView) findViewById(R.id.tv);
mTextView2= (TextView) findViewById(R.id.tv2);
mSeekBar.setOnSeekBarChangeListener(newSeekBar.OnSeekBarChangeListener() {
@Override
public voidonProgressChanged(SeekBar seekBar,intprogress,booleanfromUser) {
mTextView.setText("当前进度:"+ progress);
}
@Override
public voidonStartTrackingTouch(SeekBar seekBar) {
mTextView2.setText("press down");
}
@Override
public voidonStopTrackingTouch(SeekBar seekBar) {
mTextView2.setText("press up");
}
});
}
}
网友评论